images2neibs.h 2.4 KB
Newer Older
1 2 3 4
/**
 * \file dnn/test/common/images2neibs.h
 * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
 *
5
 * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 */
#pragma once
#include "megdnn/opr_param_defs.h"
#include "megdnn/basic_types.h"
#include <cstddef>

namespace megdnn {
namespace test {
namespace images2neibs {

struct TestArg {
    param::Images2Neibs param;
    TensorShape ishape;
    TestArg(param::Images2Neibs param, TensorShape ishape)
            : param(param), ishape(ishape) {}
};

inline std::vector<TestArg> get_args() {
    std::vector<TestArg> args;
    // clang-format off
    for (uint32_t ph : {0, 1})
    for (uint32_t pw : {0, 1})
    for (uint32_t sh : {1, 2})
    for (uint32_t sw : {1, 2})
34 35
    for (uint32_t dh : {1, 2, 3})
    for (uint32_t dw : {1, 2, 3})
36 37
    for (uint32_t wh : {3, 4})
    for (uint32_t ww : {3, 4}) {
38 39
        args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
                          TensorShape{2, 3, 19, 20});
40 41 42
    }
    // clang-format on
    // large window case
43
    args.emplace_back(param::Images2Neibs{0, 0, 1, 1, 1, 1, 32, 64},
44 45
                      TensorShape{2, 3, 96, 128});
    // large size
46
    args.emplace_back(param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
47 48 49 50 51 52 53 54 55 56 57 58
                      TensorShape{128, 128, 28, 24});

    return args;
}

inline std::vector<TestArg> get_benchmark_args() {
    std::vector<TestArg> args;
    // clang-format off
    for (uint32_t ph : {0, 1})
    for (uint32_t pw : {0, 1})
    for (uint32_t sh : {1, 2})
    for (uint32_t sw : {1, 2})
59 60
    for (uint32_t dh : {1, 2})
    for (uint32_t dw : {1, 2})
61 62 63 64 65
    for (uint32_t wh : {3, 4})
    for (uint32_t ww : {3, 4})
    for (uint32_t b : {1, 64})
    for (uint32_t c : {64, 128})
    for (uint32_t hw : {64, 128}) {
66
        args.emplace_back(param::Images2Neibs{ph, pw, sh, sw, dh, dw, wh, ww},
67 68 69 70
                          TensorShape{b, c, hw, hw});
    }
    // clang-format on
    // large size
71
    args.emplace_back(param::Images2Neibs{0, 0, 1, 1, 1, 1, 1, 1},
72 73 74 75 76 77 78 79 80 81
                      TensorShape{1024, 128, 28, 24});

    return args;
}

}  // namespace images2neibs
}  // namespace test
}  // namespace megdnn

// vim: syntax=cpp.doxygen