roi_copy.cpp 1.8 KB
Newer Older
1 2 3 4 5 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 34 35 36
/**
 * \file dnn/test/fallback/roi_copy.cpp
 * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
 *
 * Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
 *
 * 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.
 */

#include <gtest/gtest.h>

#include "megdnn.h"
#include "megdnn/oprs.h"
#include "test/common/tensor.h"
#include "test/common/roi_copy.h"
#include "test/common/checker.h"
#include "test/common/benchmarker.h"
#include "test/fallback/fixture.h"

namespace megdnn {
namespace test {

TEST_F(FALLBACK, ROICOPY) {
    using namespace roi_copy;
    std::vector<TestArg> args = get_args();
    Checker<ROICopy> checker(handle());
    checker.set_dtype(0, dtype::Int32());
    checker.set_dtype(1, dtype::Int32());

    for (auto&& arg : args) {
        checker.set_param(arg.param).execs({arg.src, {}});
    }

}
37
#if MEGDNN_WITH_BENCHMARK
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
TEST_F(FALLBACK, BENCHMARK_ROICOPY) {
    auto run = [&](const TensorShapeArray& shapes) {
        Benchmarker<ROICopy> benchmarker(handle());

        benchmarker.set_dtype(0, dtype::Int32());
        benchmarker.set_dtype(1, dtype::Int32());

        benchmarker.set_times(5);
        ROICopy::Param param;

        for (auto&& shape : shapes) {
            param.row_from = shape[1]/10;
            param.row_to = shape[1]/2;
            param.col_from = shape[2]/9;
            param.col_to = shape[2]/3 * 2;
            benchmarker.set_param(param).execs({shape, {}});
        }
#undef BENCHMARK_ROICopy
    };

    TensorShapeArray shapes = {
        {3, 1021, 980, 1},
        {3, 1021, 980, 3}
    };

    run(shapes);
}
65
#endif
66 67 68 69 70 71


}  // namespace test
}  // namespace megdnn

// vim: syntax=cpp.doxygen