ncnn

Форк
0
/
test_glu.cpp 
68 строк · 1.8 Кб
1
// Copyright (c) 2022 Xiaomi Corp.        (author: Fangjun Kuang)
2
//
3
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
4
// in compliance with the License. You may obtain a copy of the License at
5
//
6
// https://opensource.org/licenses/BSD-3-Clause
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed
9
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
11
// specific language governing permissions and limitations under the License.
12

13
#include "testutil.h"
14

15
static int test_glu(const ncnn::Mat& a, int axis)
16
{
17
    ncnn::ParamDict pd;
18
    pd.set(0, axis);
19

20
    std::vector<ncnn::Mat> weights(0);
21

22
    int ret = test_layer("GLU", pd, weights, a);
23
    if (ret != 0)
24
    {
25
        fprintf(stderr, "test_glu failed a.dims=%d a=(%d %d %d) axis=%d\n", a.dims, a.w, a.h, a.c, axis);
26
    }
27

28
    return ret;
29
}
30

31
static int test_glu_0()
32
{
33
    return 0
34
           || test_glu(RandomMat(6, 7, 24), 0)
35
           || test_glu(RandomMat(6, 8, 24), 1)
36
           || test_glu(RandomMat(6, 8, 24), 2)
37
           || test_glu(RandomMat(36, 7, 22), 0)
38
           || test_glu(RandomMat(5, 256, 23), -2)
39
           || test_glu(RandomMat(129, 9, 60), 2)
40
           || test_glu(RandomMat(129, 9, 30), -1);
41
}
42

43
static int test_glu_1()
44
{
45
    return 0
46
           || test_glu(RandomMat(10, 24), 0)
47
           || test_glu(RandomMat(7, 24), 1)
48
           || test_glu(RandomMat(128, 22), 0)
49
           || test_glu(RandomMat(128, 256), 1);
50
}
51

52
static int test_glu_2()
53
{
54
    return 0
55
           || test_glu(RandomMat(10), 0)
56
           || test_glu(RandomMat(20), 0)
57
           || test_glu(RandomMat(128), 0);
58
}
59

60
int main()
61
{
62
    SRAND(7767517);
63

64
    return 0
65
           || test_glu_0()
66
           || test_glu_1()
67
           || test_glu_2();
68
}
69

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

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

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

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