ncnn

Форк
0
/
test_concat_oom.cpp 
111 строк · 2.9 Кб
1
// Tencent is pleased to support the open source community by making ncnn available.
2
//
3
// Copyright (C) 2024 THL A29 Limited, a Tencent company. All rights reserved.
4
//
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
7
//
8
// https://opensource.org/licenses/BSD-3-Clause
9
//
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.
14

15
#include "testutil.h"
16

17
static int test_concat_oom(const std::vector<ncnn::Mat>& a, int axis)
18
{
19
    ncnn::ParamDict pd;
20
    pd.set(0, axis); //axis
21

22
    std::vector<ncnn::Mat> weights(0);
23

24
    int ret = test_layer_oom("Concat", pd, weights, a);
25
    if (ret != 0)
26
    {
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);
28
    }
29

30
    return ret;
31
}
32

33
static int test_concat_0()
34
{
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);
44

45
    return 0
46
           || test_concat_oom(as, 0)
47
           || test_concat_oom(as, 1)
48
           || test_concat_oom(as, 2)
49
           || test_concat_oom(as, 3);
50
}
51

52
static int test_concat_1()
53
{
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);
63

64
    return 0
65
           || test_concat_oom(as, 0)
66
           || test_concat_oom(as, 1)
67
           || test_concat_oom(as, 2);
68
}
69

70
static int test_concat_2()
71
{
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);
81

82
    return 0
83
           || test_concat_oom(as, 0)
84
           || test_concat_oom(as, 1);
85
}
86

87
static int test_concat_3()
88
{
89
    std::vector<ncnn::Mat> as(8);
90
    as[0] = RandomMat(6);
91
    as[1] = RandomMat(6);
92
    as[2] = RandomMat(6);
93
    as[3] = RandomMat(6);
94
    as[4] = RandomMat(6);
95
    as[5] = RandomMat(6);
96
    as[6] = RandomMat(6);
97
    as[7] = RandomMat(6);
98

99
    return test_concat_oom(as, 0);
100
}
101

102
int main()
103
{
104
    SRAND(7767517);
105

106
    return 0
107
           || test_concat_0()
108
           || test_concat_1()
109
           || test_concat_2()
110
           || test_concat_3();
111
}
112

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.