diff --git a/paddle/fluid/framework/ir/graph.h b/paddle/fluid/framework/ir/graph.h index 578824fbcad7e..9856183b4e500 100644 --- a/paddle/fluid/framework/ir/graph.h +++ b/paddle/fluid/framework/ir/graph.h @@ -86,7 +86,7 @@ namespace ir { class Graph { public: // Construct a main_graph with some sub_graphs - explicit Graph(const ProgramDesc &program); + TEST_API explicit Graph(const ProgramDesc &program); // Construct a main_graph with some sub_graphs, and the 1st sub_graph is // constructed with ops[start_op_index, end_op_index) diff --git a/paddle/fluid/framework/ir/pass.h b/paddle/fluid/framework/ir/pass.h index 753fadd242ebc..304d12cf94ecf 100644 --- a/paddle/fluid/framework/ir/pass.h +++ b/paddle/fluid/framework/ir/pass.h @@ -81,7 +81,7 @@ class Pass { std::string Type() const { return type_; } - Graph *Apply(Graph *graph) const; + TEST_API Graph *Apply(Graph *graph) const; // Get a reference to the attributed previously set. template @@ -238,7 +238,7 @@ class Registrar { class PassRegistry { public: - static PassRegistry &Instance(); + TEST_API static PassRegistry &Instance(); bool Has(const std::string &pass_type) const { return map_.find(pass_type) != map_.end(); diff --git a/paddle/phi/backends/onednn/onednn_context.h b/paddle/phi/backends/onednn/onednn_context.h index aec9f7f0d5e4f..499be34650098 100644 --- a/paddle/phi/backends/onednn/onednn_context.h +++ b/paddle/phi/backends/onednn/onednn_context.h @@ -57,7 +57,7 @@ class OneDNNContextThreadLocals { size_t get_cur_mkldnn_session_id(void); void set_cur_input_shape_str(std::string input_shape_str); void set_cur_input_shape_cache_capacity(int input_shape_cache_capacity); - void set_cur_paddle_data_layout(DataLayout dl); + TEST_API void set_cur_paddle_data_layout(DataLayout dl); DataLayout get_cur_paddle_data_layout(void); void log_lib_version(void); const dnnl::engine& get_engine(void) { return cur_engine; } @@ -77,7 +77,7 @@ class OneDNNContextThreadLocals { static constexpr size_t kMKLDNNSessionID_Default = 0; // mkldnn session id for cache clearing mode static constexpr size_t kMKLDNNSessionID_CacheClearing = -1; - static Body& fetch(); + TEST_API static Body& fetch(); }; class OneDNNContext : public CPUContext { @@ -114,7 +114,7 @@ class OneDNNContext : public CPUContext { const dnnl::engine& GetEngine() const { return tls().get_engine(); } // Remove all entries from the blob map - void ResetBlobMap(void* ptr); + TEST_API void ResetBlobMap(void* ptr); // Prevent next ResetBlobMap() void BlockNextCacheClearing(); diff --git a/test/cpp/fluid/mkldnn/CMakeLists.txt b/test/cpp/fluid/mkldnn/CMakeLists.txt index 98a48cbc0a674..2e6772a5d2eed 100644 --- a/test/cpp/fluid/mkldnn/CMakeLists.txt +++ b/test/cpp/fluid/mkldnn/CMakeLists.txt @@ -1,44 +1,8 @@ get_property(paddle_lib GLOBAL PROPERTY PADDLE_LIB_NAME) -cc_test( - test_mkldnn_op_inplace - SRCS test_mkldnn_op_inplace.cc - DEPS executor - op_registry - elementwise_add_op - activation_op - phi - common - scope - device_context - enforce - generated_static_op) -cc_test( - test_mkldnn_cpu_quantize_pass - SRCS test_mkldnn_cpu_quantize_pass.cc - DEPS executor - op_registry - activation_op - conv_activation_mkldnn_fuse_pass - cpu_quantize_placement_pass - cpu_quantize_pass - phi - common - scope - device_context) +paddle_test(test_mkldnn_op_inplace SRCS test_mkldnn_op_inplace.cc) +paddle_test(test_mkldnn_cpu_quantize_pass SRCS test_mkldnn_cpu_quantize_pass.cc) -cc_test( - test_conv_mkldnn_nhwc - SRCS test_conv_mkldnn_nhwc.cc - DEPS executor - op_registry - depthwise_conv - tensor - phi - common - scope - device_context - enforce - generated_static_op) +paddle_test(test_conv_mkldnn_nhwc SRCS test_conv_mkldnn_nhwc.cc) set(TEST_MKLDNN_CACHING_DEPS op_registry @@ -55,43 +19,15 @@ set(TEST_MKLDNN_CACHING_DEPS if(WITH_GPU OR WITH_ROCM) set(TEST_MKLDNN_CACHING_DEPS ${TEST_MKLDNN_CACHING_DEPS} depthwise_conv) endif() -cc_test( - test_mkldnn_caching - SRCS test_mkldnn_caching.cc - DEPS ${TEST_MKLDNN_CACHING_DEPS}) +paddle_test(test_mkldnn_caching SRCS test_mkldnn_caching.cc) if(WITH_TESTING) paddle_test(test_mkldnn_op_nhwc SRCS test_mkldnn_op_nhwc.cc) endif() -cc_test( - test_mkldnn_pool_adaptive_op - SRCS test_mkldnn_pool_adaptive_op.cc - DEPS fleet_executor - conditional_block_op - executor - op_registry - generated_static_op - generated_op - phi - common - scope - device_context - enforce) +paddle_test(test_mkldnn_pool_adaptive_op SRCS test_mkldnn_pool_adaptive_op.cc) -cc_test( - test_mkldnn_squeeze - SRCS test_mkldnn_squeeze.cc - DEPS fleet_executor - conditional_block_op - executor - op_registry - generated_static_op - generated_op - phi - scope - device_context - enforce) +paddle_test(test_mkldnn_squeeze SRCS test_mkldnn_squeeze.cc) if(WITH_ONNXRUNTIME AND WIN32) # Copy onnxruntime for some c++ test in Windows, since the test will diff --git a/test/cpp/fluid/mkldnn/test_conv_mkldnn_nhwc.cc b/test/cpp/fluid/mkldnn/test_conv_mkldnn_nhwc.cc index 4dfc4a731bff2..1bc92cde48a65 100644 --- a/test/cpp/fluid/mkldnn/test_conv_mkldnn_nhwc.cc +++ b/test/cpp/fluid/mkldnn/test_conv_mkldnn_nhwc.cc @@ -26,9 +26,6 @@ #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/kernel_registry.h" -USE_OP_ITSELF(conv2d); -PD_DECLARE_KERNEL(conv2d, OneDNN, ONEDNN); - template void AddVarToScope(const std::string var_name, paddle::framework::Scope* scope, diff --git a/test/cpp/fluid/mkldnn/test_mkldnn_caching.cc b/test/cpp/fluid/mkldnn/test_mkldnn_caching.cc index 0f62301cdfe6d..efa82b26783c8 100644 --- a/test/cpp/fluid/mkldnn/test_mkldnn_caching.cc +++ b/test/cpp/fluid/mkldnn/test_mkldnn_caching.cc @@ -26,17 +26,6 @@ #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/kernel_registry.h" -USE_OP_ITSELF(elementwise_add); -PD_DECLARE_KERNEL(add_raw, OneDNN, ONEDNN); -USE_OP_ITSELF(elementwise_mul); -PD_DECLARE_KERNEL(multiply_raw, OneDNN, ONEDNN); -USE_OP_ITSELF(relu); -PD_DECLARE_KERNEL(relu, OneDNN, ONEDNN); -USE_OP_ITSELF(softmax); -PD_DECLARE_KERNEL(softmax, OneDNN, ONEDNN); -USE_OP_ITSELF(conv2d); -PD_DECLARE_KERNEL(conv2d, OneDNN, ONEDNN); - namespace paddle { namespace operators { diff --git a/test/cpp/fluid/mkldnn/test_mkldnn_cpu_quantize_pass.cc b/test/cpp/fluid/mkldnn/test_mkldnn_cpu_quantize_pass.cc index d6ba2f7a0c232..b87f32dcb5a85 100644 --- a/test/cpp/fluid/mkldnn/test_mkldnn_cpu_quantize_pass.cc +++ b/test/cpp/fluid/mkldnn/test_mkldnn_cpu_quantize_pass.cc @@ -110,7 +110,3 @@ TEST(cpuQuantizePass, ConvReLU6) { } // namespace pass } // namespace paddle - -USE_PASS(conv_activation_mkldnn_fuse_pass); -USE_PASS(cpu_quantize_placement_pass); -USE_PASS(cpu_quantize_pass); diff --git a/test/cpp/fluid/mkldnn/test_mkldnn_op_inplace.cc b/test/cpp/fluid/mkldnn/test_mkldnn_op_inplace.cc index 1c1a0cfb21914..9317722e6f8d4 100644 --- a/test/cpp/fluid/mkldnn/test_mkldnn_op_inplace.cc +++ b/test/cpp/fluid/mkldnn/test_mkldnn_op_inplace.cc @@ -26,13 +26,7 @@ #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/kernel_registry.h" -USE_OP_ITSELF(elementwise_add); PD_DECLARE_KERNEL(add_raw, OneDNN, ONEDNN); -USE_OP_ITSELF(relu); -PD_DECLARE_KERNEL(relu, OneDNN, ONEDNN); -USE_OP_ITSELF(softmax); -PD_DECLARE_KERNEL(softmax, OneDNN, ONEDNN); -PD_DECLARE_KERNEL(softmax, CPU, ALL_LAYOUT); namespace paddle { namespace operators { diff --git a/test/cpp/fluid/mkldnn/test_mkldnn_pool_adaptive_op.cc b/test/cpp/fluid/mkldnn/test_mkldnn_pool_adaptive_op.cc index 3e1a9230ec231..da378c12f89f9 100644 --- a/test/cpp/fluid/mkldnn/test_mkldnn_pool_adaptive_op.cc +++ b/test/cpp/fluid/mkldnn/test_mkldnn_pool_adaptive_op.cc @@ -85,7 +85,3 @@ TEST(Pool2dOpConverter, avg_ceil_test) { test_pool2d(true, true, "avg"); } } // namespace tensorrt } // namespace inference } // namespace paddle - -USE_OP_ITSELF(pool2d); -PD_DECLARE_KERNEL(pool2d, OneDNN, ONEDNN); -PD_DECLARE_KERNEL(pool2d, CPU, ALL_LAYOUT); diff --git a/test/cpp/fluid/mkldnn/test_mkldnn_squeeze.cc b/test/cpp/fluid/mkldnn/test_mkldnn_squeeze.cc index a08ca3075ca00..343c043cb9860 100644 --- a/test/cpp/fluid/mkldnn/test_mkldnn_squeeze.cc +++ b/test/cpp/fluid/mkldnn/test_mkldnn_squeeze.cc @@ -101,6 +101,3 @@ TEST(SqueezeOpConverter_2, normal) { test_squeeze2(); } } // namespace tensorrt } // namespace inference } // namespace paddle - -USE_OP_ITSELF(squeeze2); -PD_DECLARE_KERNEL(squeeze_infer, OneDNN, ONEDNN);