diff --git a/CMakeLists.txt b/CMakeLists.txt index 536ee65589b9271fd14529ebf702f5f4af382849..ddfb4967e86b73969de61b4fbecd52a385b31290 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1089,6 +1089,11 @@ if(MGE_WITH_JIT AND MGE_WITH_HALIDE) include(cmake/Halide.cmake) endif() +if(MGE_ENABLE_EXCEPTIONS) + add_compile_definitions(CPP_REDIS_ENABLE_EXCEPTION=1) +else() + add_compile_definitions(CPP_REDIS_ENABLE_EXCEPTION=0) +endif() include(cmake/cpp_redis.cmake) # Thread @@ -1133,6 +1138,7 @@ if(MSVC OR WIN32) endif() if(CMAKE_THREAD_LIBS_INIT + OR CMAKE_HAVE_LIBC_PTHREAD OR CMAKE_USE_WIN32_THREADS_INIT OR ANDROID) set(MGB_HAVE_THREAD 1) diff --git a/dnn/test/aarch64/relayout.cpp b/dnn/test/aarch64/relayout.cpp index 53066817c8cdc52b1a1cd30b2ec65188d1a64a00..bab9d054f9811499f12d4f1847748d1e049e3643 100644 --- a/dnn/test/aarch64/relayout.cpp +++ b/dnn/test/aarch64/relayout.cpp @@ -12,7 +12,7 @@ namespace test { namespace { template class AARCH64_RELAYOUT : public AARCH64 {}; -TYPED_TEST_CASE(AARCH64_RELAYOUT, relayout::test_types); +TYPED_TEST_SUITE(AARCH64_RELAYOUT, relayout::test_types); TYPED_TEST(AARCH64_RELAYOUT, run) { relayout::run_test(this->handle()); } diff --git a/dnn/test/arm_common/elemwise.cpp b/dnn/test/arm_common/elemwise.cpp index 6563fd2331f1eb637ba0baf923aee2affb1fa0c4..fe684583196d7acfc3dc04cc50446987c98f6273 100644 --- a/dnn/test/arm_common/elemwise.cpp +++ b/dnn/test/arm_common/elemwise.cpp @@ -12,14 +12,14 @@ using namespace test; template class ARM_ELEMWISE : public ARM_COMMON {}; -TYPED_TEST_CASE(ARM_ELEMWISE, elemwise::test_types); +TYPED_TEST_SUITE(ARM_ELEMWISE, elemwise::test_types); TYPED_TEST(ARM_ELEMWISE, run) { elemwise::run_test(this->handle()); } template class ARM_ELEMWISE_MULTI_THREADS : public ARM_COMMON_MULTI_THREADS {}; -TYPED_TEST_CASE(ARM_ELEMWISE_MULTI_THREADS, elemwise::test_types); +TYPED_TEST_SUITE(ARM_ELEMWISE_MULTI_THREADS, elemwise::test_types); TYPED_TEST(ARM_ELEMWISE_MULTI_THREADS, run) { elemwise::run_test(this->handle()); } diff --git a/dnn/test/arm_common/elemwise_multi_type.cpp b/dnn/test/arm_common/elemwise_multi_type.cpp index 9e46d4f6c894c1a4cd81262eadd500c1a4a5a9ab..6295045ca53008253a9409c0a136b5ff89f34e9a 100644 --- a/dnn/test/arm_common/elemwise_multi_type.cpp +++ b/dnn/test/arm_common/elemwise_multi_type.cpp @@ -14,7 +14,7 @@ using namespace test; namespace { template class ARM_COMMON_ELEMWISE_MULTI_TYPE : public ARM_COMMON {}; -TYPED_TEST_CASE(ARM_COMMON_ELEMWISE_MULTI_TYPE, elemwise_multi_type::test_types); +TYPED_TEST_SUITE(ARM_COMMON_ELEMWISE_MULTI_TYPE, elemwise_multi_type::test_types); } // anonymous namespace TYPED_TEST(ARM_COMMON_ELEMWISE_MULTI_TYPE, run) { diff --git a/dnn/test/common/small_vector.cpp b/dnn/test/common/small_vector.cpp index be045d7f5f413e48aecb8ef8b5fb72b2d6ac636b..1b8dedc91efc76d9fcb6578a354bf2d23b4d769f 100644 --- a/dnn/test/common/small_vector.cpp +++ b/dnn/test/common/small_vector.cpp @@ -231,7 +231,7 @@ typedef ::testing::Types< SmallVector, SmallVector, SmallVector> SmallVectorTestTypes; -TYPED_TEST_CASE(SmallVectorTest, SmallVectorTestTypes); +TYPED_TEST_SUITE(SmallVectorTest, SmallVectorTestTypes); // Constructor test. TYPED_TEST(SmallVectorTest, ConstructorNonIterTest) { SCOPED_TRACE("ConstructorTest"); @@ -836,7 +836,7 @@ typedef ::testing::Types< std::pair, SmallVector>> DualSmallVectorTestTypes; -TYPED_TEST_CASE(DualSmallVectorsTest, DualSmallVectorTestTypes); +TYPED_TEST_SUITE(DualSmallVectorsTest, DualSmallVectorTestTypes); TYPED_TEST(DualSmallVectorsTest, MoveAssignment) { SCOPED_TRACE("MoveAssignTest-DualVectorTypes"); diff --git a/dnn/test/cpu/relayout.cpp b/dnn/test/cpu/relayout.cpp index 680d8a5486b3951881fe96f215078992738a5c96..6303ac454408b94b8f7eae54cb43795cfd486414 100644 --- a/dnn/test/cpu/relayout.cpp +++ b/dnn/test/cpu/relayout.cpp @@ -12,7 +12,7 @@ using namespace test; namespace { template class CPU_RELAYOUT : public CPU {}; -TYPED_TEST_CASE(CPU_RELAYOUT, relayout::test_types); +TYPED_TEST_SUITE(CPU_RELAYOUT, relayout::test_types); TYPED_TEST(CPU_RELAYOUT, run) { relayout::run_test(this->handle()); } diff --git a/dnn/test/cuda/elemwise.cpp b/dnn/test/cuda/elemwise.cpp index 92bfa4918188d6c18b0f42bd74e688030060f716..3a8d6b187111d8eaae710188e394b2b94fd6ea17 100644 --- a/dnn/test/cuda/elemwise.cpp +++ b/dnn/test/cuda/elemwise.cpp @@ -71,7 +71,7 @@ void run_tensor_add( template class CUDA_ELEMWISE : public CUDA {}; -TYPED_TEST_CASE(CUDA_ELEMWISE, elemwise::test_types); +TYPED_TEST_SUITE(CUDA_ELEMWISE, elemwise::test_types); TYPED_TEST(CUDA_ELEMWISE, run) { elemwise::run_test(this->handle_cuda()); } diff --git a/dnn/test/cuda/elemwise_multi_type.cpp b/dnn/test/cuda/elemwise_multi_type.cpp index 96b4b944a43fe7b0b7892880a7447758812a2249..a346d966f7f98696bd6e983034608bda07d13b01 100644 --- a/dnn/test/cuda/elemwise_multi_type.cpp +++ b/dnn/test/cuda/elemwise_multi_type.cpp @@ -13,7 +13,7 @@ using namespace test; namespace { template class CUDA_ELEMWISE_MULTI_TYPE : public CUDA {}; -TYPED_TEST_CASE(CUDA_ELEMWISE_MULTI_TYPE, elemwise_multi_type::test_types); +TYPED_TEST_SUITE(CUDA_ELEMWISE_MULTI_TYPE, elemwise_multi_type::test_types); } // anonymous namespace TYPED_TEST(CUDA_ELEMWISE_MULTI_TYPE, run) { diff --git a/dnn/test/cuda/relayout.cpp b/dnn/test/cuda/relayout.cpp index 030b227e59f965bf63815e51832db2f9e08504b8..cf99b9942b6e87ad0939b9773ac798ea525914af 100644 --- a/dnn/test/cuda/relayout.cpp +++ b/dnn/test/cuda/relayout.cpp @@ -11,7 +11,7 @@ using namespace test; namespace { template class CUDA_RELAYOUT : public CUDA {}; -TYPED_TEST_CASE(CUDA_RELAYOUT, relayout::test_types); +TYPED_TEST_SUITE(CUDA_RELAYOUT, relayout::test_types); TYPED_TEST(CUDA_RELAYOUT, run) { relayout::run_test(this->handle_cuda()); } diff --git a/dnn/test/fallback/elemwise.cpp b/dnn/test/fallback/elemwise.cpp index 84122b7f161d16808ca18ad918f1724c145d71f9..9495f544f4a61057cdc5f9f7145a5068fa1b26fd 100644 --- a/dnn/test/fallback/elemwise.cpp +++ b/dnn/test/fallback/elemwise.cpp @@ -11,7 +11,7 @@ using namespace test; template class FALLBACK_ELEMWISE : public FALLBACK {}; -TYPED_TEST_CASE(FALLBACK_ELEMWISE, elemwise::test_types); +TYPED_TEST_SUITE(FALLBACK_ELEMWISE, elemwise::test_types); TYPED_TEST(FALLBACK_ELEMWISE, run) { elemwise::run_test(this->handle()); } diff --git a/dnn/test/fallback/elemwise_multi_type.cpp b/dnn/test/fallback/elemwise_multi_type.cpp index 0ec57b2bfecd8f42e3806669011ebc1d46fd138e..05a53cc0e2f9496ea39ef3a875996e58493c6d32 100644 --- a/dnn/test/fallback/elemwise_multi_type.cpp +++ b/dnn/test/fallback/elemwise_multi_type.cpp @@ -8,7 +8,7 @@ using namespace test; namespace { template class FALLBACK_ELEMWISE_MULTI_TYPE : public FALLBACK {}; -TYPED_TEST_CASE(FALLBACK_ELEMWISE_MULTI_TYPE, elemwise_multi_type::test_types); +TYPED_TEST_SUITE(FALLBACK_ELEMWISE_MULTI_TYPE, elemwise_multi_type::test_types); } // anonymous namespace TYPED_TEST(FALLBACK_ELEMWISE_MULTI_TYPE, run) { diff --git a/dnn/test/fallback/relayout.cpp b/dnn/test/fallback/relayout.cpp index 75ef5ec519e903fe5290dd38de286778d0ac9a49..758bfff95b1c90b138635600c22447ba8733fcdf 100644 --- a/dnn/test/fallback/relayout.cpp +++ b/dnn/test/fallback/relayout.cpp @@ -14,7 +14,7 @@ using namespace test; namespace { template class FALLBACK_RELAYOUT : public FALLBACK {}; -TYPED_TEST_CASE(FALLBACK_RELAYOUT, relayout::test_types); +TYPED_TEST_SUITE(FALLBACK_RELAYOUT, relayout::test_types); TYPED_TEST(FALLBACK_RELAYOUT, run) { relayout::run_test(this->handle()); } diff --git a/dnn/test/rocm/elemwise.cpp b/dnn/test/rocm/elemwise.cpp index 0df11bc6d87ffc9d00fc49c93ab453fafe4b298e..8beb3fd81e901069b900a07f54583d35e4a2c871 100644 --- a/dnn/test/rocm/elemwise.cpp +++ b/dnn/test/rocm/elemwise.cpp @@ -52,7 +52,7 @@ void run_elemwise_benchmark( template class ROCM_ELEMWISE : public ROCM {}; -TYPED_TEST_CASE(ROCM_ELEMWISE, elemwise::test_types); +TYPED_TEST_SUITE(ROCM_ELEMWISE, elemwise::test_types); TYPED_TEST(ROCM_ELEMWISE, run) { elemwise::run_test(this->handle_rocm()); } diff --git a/dnn/test/rocm/relayout.cpp b/dnn/test/rocm/relayout.cpp index c0cef5d49e34df473e4e30356c22622e759dbb53..49647b266814b062f80a040a2826a837cb1d9f2b 100644 --- a/dnn/test/rocm/relayout.cpp +++ b/dnn/test/rocm/relayout.cpp @@ -13,7 +13,7 @@ using namespace test; namespace { template class ROCM_RELAYOUT : public ROCM {}; -TYPED_TEST_CASE(ROCM_RELAYOUT, relayout::test_types); +TYPED_TEST_SUITE(ROCM_RELAYOUT, relayout::test_types); TYPED_TEST(ROCM_RELAYOUT, run) { relayout::run_test(this->handle_rocm()); } diff --git a/dnn/test/x86/elemwise.cpp b/dnn/test/x86/elemwise.cpp index 92988559ab33b663532677bded2dc66827e72ced..47c215f30c6310214890816197d9d50bfcfe4eb7 100644 --- a/dnn/test/x86/elemwise.cpp +++ b/dnn/test/x86/elemwise.cpp @@ -212,7 +212,7 @@ TEST_F(X86, ELEMWISE_FORWARD_TERNARY) { template class X86_ELEMWISE : public X86 {}; -TYPED_TEST_CASE(X86_ELEMWISE, elemwise::test_types); +TYPED_TEST_SUITE(X86_ELEMWISE, elemwise::test_types); TYPED_TEST(X86_ELEMWISE, run) { elemwise::run_test(this->handle()); } diff --git a/dnn/test/x86/elemwise_multi_type.cpp b/dnn/test/x86/elemwise_multi_type.cpp index 8f2bc054d4b8efcaf239b5f9453fe12fd15bafd5..47242c25fe4505b1c5421be4233ea73a9fa78e57 100644 --- a/dnn/test/x86/elemwise_multi_type.cpp +++ b/dnn/test/x86/elemwise_multi_type.cpp @@ -11,7 +11,7 @@ using namespace test; namespace { template class X86_ELEMWISE_MULTI_TYPE : public X86 {}; -TYPED_TEST_CASE(X86_ELEMWISE_MULTI_TYPE, elemwise_multi_type::test_types); +TYPED_TEST_SUITE(X86_ELEMWISE_MULTI_TYPE, elemwise_multi_type::test_types); } // anonymous namespace TYPED_TEST(X86_ELEMWISE_MULTI_TYPE, run) { diff --git a/imperative/src/include/megbrain/imperative/utils/platform.h b/imperative/src/include/megbrain/imperative/utils/platform.h index 843e229d7188b808dc0c7f0806b9491f356e4d74..c191b12ad6484b2eaf607727b2135e8e4c7a4698 100644 --- a/imperative/src/include/megbrain/imperative/utils/platform.h +++ b/imperative/src/include/megbrain/imperative/utils/platform.h @@ -1,7 +1,7 @@ #pragma once #include - +#include namespace mgb::imperative { std::string demangle(std::string mangled); diff --git a/src/core/test/comp_node.cpp b/src/core/test/comp_node.cpp index e36d1fdeb841a27d7d25d60fcc31b04bfcadafeb..506e4fe02bb30989c5a3c751f1a6c7e396605eab 100644 --- a/src/core/test/comp_node.cpp +++ b/src/core/test/comp_node.cpp @@ -789,7 +789,7 @@ TEST(TestCompNode, DepedentObjectList) { namespace { template class TestCPUCompSeqRec : public ::testing::Test {}; -TYPED_TEST_CASE(TestCPUCompSeqRec, comp_node_test::seq_rec::test_types); +TYPED_TEST_SUITE(TestCPUCompSeqRec, comp_node_test::seq_rec::test_types); TYPED_TEST(TestCPUCompSeqRec, run) { comp_node_test::seq_rec::run(CompNode::load("cpux")); } diff --git a/src/core/test/static_mem_alloc.cpp b/src/core/test/static_mem_alloc.cpp index 231c091b22c603969765a4f1ebee253f57400b9a..0faf058e35c4a233e6a0cbb667ed2ff685f28f26 100644 --- a/src/core/test/static_mem_alloc.cpp +++ b/src/core/test/static_mem_alloc.cpp @@ -124,7 +124,7 @@ TEST_P(BasicCorrectness, OverwriteSameEnd) { ASSERT_EQ(align(1 + padding()), allocator->tot_alloc_lower_bound()); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( TestStaticMemAllocAlgo, BasicCorrectness, TestParam::make_values({1, 2}, {1, 2}, {1})); @@ -207,7 +207,7 @@ TEST_P(RandomOpr, Main) { timer.get_secs(), sz_tot, sz_lower, double(sz_tot) / sz_lower - 1); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( TestStaticMemAllocAlgo, RandomOpr, TestParam::make_values( {1, 256}, {1, 32}, {10, INTERVAL_MOVE_MAX_SIZE, 1000, 10000})); diff --git a/src/gopt/test/basic_arith.cpp b/src/gopt/test/basic_arith.cpp index 483cc7af32f1de9483f46d5151cfbcf269f1e461..0be30754df539d85aee516a2d66c594200ca0268 100644 --- a/src/gopt/test/basic_arith.cpp +++ b/src/gopt/test/basic_arith.cpp @@ -107,11 +107,13 @@ TEST(TestGoptBasicArithInplace, Absorbing) { ASSERT_EQ(y.as_immutable_scalar()->get_cast(), 0.f); } +namespace { auto gen_postive = [](HostTensorND& dest) { HostTensorGenerator mask_generator{ 2.f, 4.f}; dest = *mask_generator(dest.shape(), dest.comp_node()); }; +}; TEST(TestGoptBasicArithInplace, LogExpExpand) { // test log(exp(a) * (exp(b) / (exp(c) * d**2))) -> a + b - c - log(d**2) diff --git a/src/jit/test/codegen.cpp b/src/jit/test/codegen.cpp index ab407a422a01702e583e5bddb94ffc778134e8bf..189689697f2edc972686ab22260e776bd752e073 100644 --- a/src/jit/test/codegen.cpp +++ b/src/jit/test/codegen.cpp @@ -290,7 +290,7 @@ void run_mlir_mode(CompNode cn) { #if MGB_JIT_HALIDE template class TestJITHalideCodeGenCuda : public ::testing::Test {}; -TYPED_TEST_CASE(TestJITHalideCodeGenCuda, test_types); +TYPED_TEST_SUITE(TestJITHalideCodeGenCuda, test_types); TYPED_TEST(TestJITHalideCodeGenCuda, run) { REQUIRE_GPU(1); run(Backend::HALIDE, CompNode::load("gpu0")); @@ -301,7 +301,7 @@ TYPED_TEST(TestJITHalideCodeGenCuda, run) { template class TestJITNvrtcCodeGen : public ::testing::Test {}; -TYPED_TEST_CASE(TestJITNvrtcCodeGen, test_types); +TYPED_TEST_SUITE(TestJITNvrtcCodeGen, test_types); TYPED_TEST(TestJITNvrtcCodeGen, run) { REQUIRE_GPU(1); run(Backend::NVRTC, CompNode::load("gpu0")); @@ -344,7 +344,7 @@ FOREACH_UNARY_MODE(def_tag) #define t(n) n, using mlir_elemwise_unary_types = ::testing::Types; #undef t -TYPED_TEST_CASE(TestJITMlirUnaryElemwise, mlir_elemwise_unary_types); +TYPED_TEST_SUITE(TestJITMlirUnaryElemwise, mlir_elemwise_unary_types); #define SKIP_MODE(_mode) \ if (TypeParam::mode == opr::Elemwise::Mode::_mode) { \ @@ -390,7 +390,7 @@ FOREACH_BINARY_MODE(def_tag) #define t(n) n, using mlir_elemwise_binary_types = ::testing::Types; #undef t -TYPED_TEST_CASE(TestJITMlirBinaryElemwise, mlir_elemwise_binary_types); +TYPED_TEST_SUITE(TestJITMlirBinaryElemwise, mlir_elemwise_binary_types); TYPED_TEST(TestJITMlirBinaryElemwise, run) { auto cn = CompNode::load("cpu0"); run_mlir_mode(cn); @@ -422,7 +422,7 @@ FOREACH_TERNARY_MODE(def_tag) using mlir_elemwise_ternary_types = ::testing::Types; #undef t -TYPED_TEST_CASE(TestJITMlirTernaryElemwise, mlir_elemwise_ternary_types); +TYPED_TEST_SUITE(TestJITMlirTernaryElemwise, mlir_elemwise_ternary_types); TYPED_TEST(TestJITMlirTernaryElemwise, run) { auto cn = CompNode::load("cpu0"); run_mlir_mode(cn); diff --git a/src/jit/test/fusion.cpp b/src/jit/test/fusion.cpp index 2b768cdc461050bcdeb8867fddb6a98701f4aa3a..335a9d9297da1e03f83a61db045d36fa6eda7621 100644 --- a/src/jit/test/fusion.cpp +++ b/src/jit/test/fusion.cpp @@ -1147,7 +1147,7 @@ TEST(TestJITFusionHalide, SameGradOpr) { template class TestJITHalideFusionCuda : public ::testing::Test {}; -TYPED_TEST_CASE(TestJITHalideFusionCuda, test_types); +TYPED_TEST_SUITE(TestJITHalideFusionCuda, test_types); TYPED_TEST(TestJITHalideFusionCuda, run) { set_backend(Backend::NONE); @@ -1160,7 +1160,7 @@ TYPED_TEST(TestJITHalideFusionCuda, run) { template class TestJITNvrtcFusion : public ::testing::Test {}; -TYPED_TEST_CASE(TestJITNvrtcFusion, test_types); +TYPED_TEST_SUITE(TestJITNvrtcFusion, test_types); TYPED_TEST(TestJITNvrtcFusion, run) { set_backend(Backend::NONE); diff --git a/src/opr/test/basic_arith/elemwise.cpp b/src/opr/test/basic_arith/elemwise.cpp index 85b7734a1654073114e786f842308fc5ef08db0d..7f6fe6a7a91ce2199a4e56cc1fede088455583d0 100644 --- a/src/opr/test/basic_arith/elemwise.cpp +++ b/src/opr/test/basic_arith/elemwise.cpp @@ -812,7 +812,7 @@ typedef ::testing::Types< void // extra void to consume last comma > UnaryTraitTypes; -TYPED_TEST_CASE(TestOprBasicArithUnaryElemwise, UnaryTraitTypes); +TYPED_TEST_SUITE(TestOprBasicArithUnaryElemwise, UnaryTraitTypes); typedef ::testing::Types< #define DEF_TRAIT(_mode, _expr) _mode, @@ -821,7 +821,7 @@ typedef ::testing::Types< void // extra void to consume last comma > BinaryTraitTypes; -TYPED_TEST_CASE(TestOprBasicArithBinaryElemwise, BinaryTraitTypes); +TYPED_TEST_SUITE(TestOprBasicArithBinaryElemwise, BinaryTraitTypes); typedef ::testing::Types< #define DEF_TRAIT(_mode, _expr) _mode, @@ -830,7 +830,7 @@ typedef ::testing::Types< void // extra void to consume last comma > TernaryTraitTypes; -TYPED_TEST_CASE(TestOprBasicArithTernaryElemwise, TernaryTraitTypes); +TYPED_TEST_SUITE(TestOprBasicArithTernaryElemwise, TernaryTraitTypes); } // anonymous namespace