1
// Tencent is pleased to support the open source community by making ncnn available.
3
// Copyright (C) 2024 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_concat_oom(const std::vector<ncnn::Mat>& a, int axis)
20
pd.set(0, axis); //axis
22
std::vector<ncnn::Mat> weights(0);
24
int ret = test_layer_oom("Concat", pd, weights, a);
27
fprintf(stderr, "test_concat_oom failed a[0].dims=%d a[0]=(%d %d %d %d) axis=%d\n", a[0].dims, a[0].w, a[0].h, a[0].d, a[0].c, axis);
33
static int test_concat_0()
35
std::vector<ncnn::Mat> as(8);
36
as[0] = RandomMat(6, 6, 6, 6);
37
as[1] = RandomMat(6, 6, 6, 6);
38
as[2] = RandomMat(6, 6, 6, 6);
39
as[3] = RandomMat(6, 6, 6, 6);
40
as[4] = RandomMat(6, 6, 6, 6);
41
as[5] = RandomMat(6, 6, 6, 6);
42
as[6] = RandomMat(6, 6, 6, 6);
43
as[7] = RandomMat(6, 6, 6, 6);
46
|| test_concat_oom(as, 0)
47
|| test_concat_oom(as, 1)
48
|| test_concat_oom(as, 2)
49
|| test_concat_oom(as, 3);
52
static int test_concat_1()
54
std::vector<ncnn::Mat> as(8);
55
as[0] = RandomMat(6, 6, 6);
56
as[1] = RandomMat(6, 6, 6);
57
as[2] = RandomMat(6, 6, 6);
58
as[3] = RandomMat(6, 6, 6);
59
as[4] = RandomMat(6, 6, 6);
60
as[5] = RandomMat(6, 6, 6);
61
as[6] = RandomMat(6, 6, 6);
62
as[7] = RandomMat(6, 6, 6);
65
|| test_concat_oom(as, 0)
66
|| test_concat_oom(as, 1)
67
|| test_concat_oom(as, 2);
70
static int test_concat_2()
72
std::vector<ncnn::Mat> as(8);
73
as[0] = RandomMat(6, 6);
74
as[1] = RandomMat(6, 6);
75
as[2] = RandomMat(6, 6);
76
as[3] = RandomMat(6, 6);
77
as[4] = RandomMat(6, 6);
78
as[5] = RandomMat(6, 6);
79
as[6] = RandomMat(6, 6);
80
as[7] = RandomMat(6, 6);
83
|| test_concat_oom(as, 0)
84
|| test_concat_oom(as, 1);
87
static int test_concat_3()
89
std::vector<ncnn::Mat> as(8);
99
return test_concat_oom(as, 0);