mirror of
https://github.com/Tencent/ncnn.git
synced 2026-10-17 04:41:47 +08:00
5ea98309e3
* harden layer parameter validation Original patches and author identities: https://github.com/Tencent/ncnn/pull/6912 (beilzx) https://github.com/Tencent/ncnn/pull/6919 (FluxMind-O) https://github.com/Tencent/ncnn/pull/6928 (lxcxjxhx) https://github.com/Tencent/ncnn/pull/6948 (ktz03) https://github.com/Tencent/ncnn/pull/6950 (ktz03) https://github.com/Tencent/ncnn/pull/6971 (LI) https://github.com/Tencent/ncnn/pull/6974 (LI) https://github.com/Tencent/ncnn/pull/6977 (LI) Co-authored-by: beilzx <2069360659@qq.com> Co-authored-by: FluxMind-O <3283918317@qq.com> Co-authored-by: lxcxjxhx <lxcxjxhx@users.noreply.github.com> Co-authored-by: ktz03 <2484593937@qq.com> Co-authored-by: LI <2484593937@qq.com>
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
// Copyright 2026 Tencent
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
#include "testutil.h"
|
|
|
|
#include "layer_type.h"
|
|
|
|
#include <limits.h>
|
|
|
|
#if NCNN_VALIDATION
|
|
static int test_spp_load_param()
|
|
{
|
|
ncnn::ParamDict base;
|
|
if (test_layer_param(ncnn::LayerType::SPP, base, 0) != 0)
|
|
return -1;
|
|
|
|
for (int i = 0; i <= 1; i++)
|
|
{
|
|
if (test_layer_param(ncnn::LayerType::SPP, base, 0, i, 0) != 0)
|
|
return -1;
|
|
}
|
|
|
|
const int invalid[] = {-1, 2, INT_MIN, INT_MAX};
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
if (test_layer_param(ncnn::LayerType::SPP, base, 0, invalid[i], -1) != 0)
|
|
return -1;
|
|
}
|
|
|
|
for (int i = 1; i <= 15; i++)
|
|
{
|
|
if (test_layer_param(ncnn::LayerType::SPP, base, 1, i, 0) != 0)
|
|
return -1;
|
|
}
|
|
|
|
const int invalid_height[] = {-1, 0, 16, INT_MIN, INT_MAX};
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
if (test_layer_param(ncnn::LayerType::SPP, base, 1, invalid_height[i], -1) != 0)
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
#endif // NCNN_VALIDATION
|
|
|
|
int main()
|
|
{
|
|
SRAND(7767517);
|
|
|
|
return 0
|
|
#if NCNN_VALIDATION
|
|
|| test_spp_load_param()
|
|
#endif // NCNN_VALIDATION
|
|
;
|
|
}
|