check_non_finite.cpp 1.4 KB
Newer Older
1
/**
2
 * \file dnn/test/cuda/check_non_finite.cpp
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
 *
 * Copyright (c) 2014-2021 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 "megdnn/oprs.h"
#include "test/common/checker.h"
#include "test/cuda/fixture.h"

namespace megdnn {
namespace test {

18 19
TEST_F(CUDA, CHECK_NON_FINITE_BASIC) {
    Checker<CheckNonFinite> checker(handle_cuda());
20 21
    checker.set_allow_invalid_check(true);
    const auto inf = std::numeric_limits<float>::infinity();
22
    const auto nan = std::numeric_limits<float>::quiet_NaN();
23 24
    UniformFloatWithValueRNG rng(-1.0f, 1.0f, 0.1f, inf);
    checker.set_rng(0, &rng);
25
    checker.execs({{512 * 4}, {4}, {1}});
26 27
    rng = UniformFloatWithValueRNG(-1.0f, 1.0f, 1.f, inf);
    checker.set_rng(0, &rng);
28
    checker.execs({{4}, {512 * 4}, {1}});
29 30
    rng = UniformFloatWithValueRNG(-1.0f, 1.0f, 1.f, nan);
    checker.set_rng(0, &rng);
31 32 33 34
    checker.execs({{32}, {256}, {1}});
    rng = UniformFloatWithValueRNG(-1.0f, 1.0f, 0.f, nan);
    checker.set_rng(0, &rng);
    checker.execs({{16}, {16}, {2}, {1}});
35 36 37 38 39 40
}

}  // namespace test
}  // namespace megdnn

// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}