1
// Tencent is pleased to support the open source community by making ncnn available.
3
// Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
5
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6
// in compliance with the License. You may obtain a copy of the License at
8
// https://opensource.org/licenses/BSD-3-Clause
10
// Unless required by applicable law or agreed to in writing, software distributed
11
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
// specific language governing permissions and limitations under the License.
17
static int test_celu(const ncnn::Mat& a, float alpha)
22
std::vector<ncnn::Mat> weights(0);
24
int ret = test_layer("CELU", pd, weights, a);
27
fprintf(stderr, "test_celu failed a.dims=%d a=(%d %d %d %d) alpha=%f\n", a.dims, a.w, a.h, a.d, a.c, alpha);
33
static int test_celu_0()
36
|| test_celu(RandomMat(3, 8, 12, 18), 1.f)
37
|| test_celu(RandomMat(4, 7, 9, 16), 0.1f)
38
|| test_celu(RandomMat(3, 5, 12, 16), 1.f)
39
|| test_celu(RandomMat(9, 6, 7, 14), 0.1f)
40
|| test_celu(RandomMat(5, 6, 9, 10), 1.f)
41
|| test_celu(RandomMat(6, 8, 2, 15), 0.1f);
44
static int test_celu_1()
47
|| test_celu(RandomMat(7, 6, 18), 1.f)
48
|| test_celu(RandomMat(9, 6, 15), 0.1f)
49
|| test_celu(RandomMat(9, 7, 16), 1.f)
50
|| test_celu(RandomMat(6, 10, 15), 0.1f)
51
|| test_celu(RandomMat(2, 7, 11), 1.f)
52
|| test_celu(RandomMat(6, 10, 7), 0.1f);
55
static int test_celu_2()
58
|| test_celu(RandomMat(12, 18), 1.f)
59
|| test_celu(RandomMat(18, 12), 0.1f)
60
|| test_celu(RandomMat(23, 27), 1.f)
61
|| test_celu(RandomMat(18, 16), 0.1f)
62
|| test_celu(RandomMat(18, 16), 1.f)
63
|| test_celu(RandomMat(20, 16), 0.1f);
66
static int test_celu_3()
69
|| test_celu(RandomMat(256), 1.f)
70
|| test_celu(RandomMat(64), 0.1f)
71
|| test_celu(RandomMat(128), 1.f)
72
|| test_celu(RandomMat(96), 0.1f)
73
|| test_celu(RandomMat(128), 1.f)
74
|| test_celu(RandomMat(128), 0.1f);