diff --git a/paddle/fluid/operators/math/beam_search.cc b/paddle/fluid/operators/math/beam_search.cc index aeff6c394c429..f422312248c0b 100644 --- a/paddle/fluid/operators/math/beam_search.cc +++ b/paddle/fluid/operators/math/beam_search.cc @@ -25,18 +25,18 @@ namespace math { template class BeamSearchFunctor { public: - void operator()(const phi::CPUContext &context UNUSED, - const phi::DenseTensor *pre_ids, - const phi::DenseTensor *pre_scores, - const phi::DenseTensor *ids, - const phi::DenseTensor *scores, - phi::DenseTensor *selected_ids, - phi::DenseTensor *selected_scores, - phi::DenseTensor *parent_idx, - size_t level, - size_t beam_size, - int end_id, - bool is_accumulated) { + TEST_API void operator()(const phi::CPUContext &context UNUSED, + const phi::DenseTensor *pre_ids, + const phi::DenseTensor *pre_scores, + const phi::DenseTensor *ids, + const phi::DenseTensor *scores, + phi::DenseTensor *selected_ids, + phi::DenseTensor *selected_scores, + phi::DenseTensor *parent_idx, + size_t level, + size_t beam_size, + int end_id, + bool is_accumulated) { auto abs_lod = framework::ToAbsOffset(scores->lod()); auto &high_level = abs_lod[level]; diff --git a/paddle/fluid/operators/math/beam_search.h b/paddle/fluid/operators/math/beam_search.h index 4586d6a2627c1..8a4e6780a329a 100644 --- a/paddle/fluid/operators/math/beam_search.h +++ b/paddle/fluid/operators/math/beam_search.h @@ -105,18 +105,18 @@ class BeamSearchFunctor { * Return false if all the input tensor is empty, in machine translation task * that means no candidates is provided, and the task will stop running. */ - void operator()(const DeviceContext& context, - const phi::DenseTensor* pre_ids, - const phi::DenseTensor* pre_scores, - const phi::DenseTensor* ids, - const phi::DenseTensor* scores, - phi::DenseTensor* selected_ids, - phi::DenseTensor* selected_scores, - phi::DenseTensor* parent_idx, - size_t level, - size_t beam_size, - int end_id, - bool is_accumulated); + TEST_API void operator()(const DeviceContext& context, + const phi::DenseTensor* pre_ids, + const phi::DenseTensor* pre_scores, + const phi::DenseTensor* ids, + const phi::DenseTensor* scores, + phi::DenseTensor* selected_ids, + phi::DenseTensor* selected_scores, + phi::DenseTensor* parent_idx, + size_t level, + size_t beam_size, + int end_id, + bool is_accumulated); }; } // namespace math diff --git a/paddle/fluid/operators/math/concat_and_split.h b/paddle/fluid/operators/math/concat_and_split.h index 83513caa14573..5000a5ce8b656 100644 --- a/paddle/fluid/operators/math/concat_and_split.h +++ b/paddle/fluid/operators/math/concat_and_split.h @@ -35,12 +35,12 @@ namespace math { * [5,6]] */ template -class ConcatFunctor { +class TEST_API ConcatFunctor { public: - void operator()(const DeviceContext& context, - const std::vector& input, - int axis, - phi::DenseTensor* output); + TEST_API void operator()(const DeviceContext& context, + const std::vector& input, + int axis, + phi::DenseTensor* output); }; /* diff --git a/paddle/phi/backends/dynload/port.h b/paddle/phi/backends/dynload/port.h index 03a2863e4dc4e..7c475b9af68a0 100644 --- a/paddle/phi/backends/dynload/port.h +++ b/paddle/phi/backends/dynload/port.h @@ -15,6 +15,7 @@ #pragma once #include +#include "paddle/utils/test_macros.h" #define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h @@ -42,7 +43,7 @@ void *dlsym(void *handle, const char *symbol_name); void *dlopen(const char *filename, int flag); -int gettimeofday(struct timeval *tp, void *tzp); +TEST_API int gettimeofday(struct timeval *tp, void *tzp); #endif // !_WIN32 void ExecShellCommand(const std::string &cmd, std::string *message); diff --git a/paddle/phi/kernels/funcs/im2col.h b/paddle/phi/kernels/funcs/im2col.h index c6b8d22b8c60c..a27281ba8f81f 100644 --- a/paddle/phi/kernels/funcs/im2col.h +++ b/paddle/phi/kernels/funcs/im2col.h @@ -86,25 +86,25 @@ enum class ColFormat { kCFO = 0, kOCF = 1 }; template class Im2ColFunctor { public: - void operator()(const DeviceContext& context, - const phi::DenseTensor& im, - const std::vector& dilation, - const std::vector& stride, - const std::vector& padding, - phi::DenseTensor* col, - const DataLayout data_layout = DataLayout::kNCHW); + TEST_API void operator()(const DeviceContext& context, + const phi::DenseTensor& im, + const std::vector& dilation, + const std::vector& stride, + const std::vector& padding, + phi::DenseTensor* col, + const DataLayout data_layout = DataLayout::kNCHW); }; template class Col2ImFunctor { public: - void operator()(const DeviceContext& context, - const phi::DenseTensor& col, - const std::vector& dilation, - const std::vector& stride, - const std::vector& padding, - phi::DenseTensor* im, - const DataLayout data_layout = DataLayout::kNCHW); + TEST_API void operator()(const DeviceContext& context, + const phi::DenseTensor& col, + const std::vector& dilation, + const std::vector& stride, + const std::vector& padding, + phi::DenseTensor* im, + const DataLayout data_layout = DataLayout::kNCHW); }; } // namespace funcs diff --git a/paddle/phi/kernels/funcs/math_function.h b/paddle/phi/kernels/funcs/math_function.h index 509f3f0d6b9b5..31abf949b8a4b 100644 --- a/paddle/phi/kernels/funcs/math_function.h +++ b/paddle/phi/kernels/funcs/math_function.h @@ -59,9 +59,9 @@ struct Transpose { template struct SetConstant { - void operator()(const DeviceContext& context, - phi::DenseTensor* tensor, - T num); + TEST_API void operator()(const DeviceContext& context, + phi::DenseTensor* tensor, + T num); }; #ifdef PADDLE_WITH_XPU diff --git a/paddle/phi/kernels/funcs/selected_rows_functor.h b/paddle/phi/kernels/funcs/selected_rows_functor.h index c072f7ff12e88..16005964502f4 100644 --- a/paddle/phi/kernels/funcs/selected_rows_functor.h +++ b/paddle/phi/kernels/funcs/selected_rows_functor.h @@ -33,37 +33,37 @@ namespace funcs { // SelectedRows + SelectedRows will simply concat value and rows. // The real computation happens in dealing with LoDTensor. template -struct SelectedRowsAdd { - void operator()(const DeviceContext& context, - const phi::SelectedRows& input1, - const phi::SelectedRows& input2, - phi::SelectedRows* output); +struct TEST_API SelectedRowsAdd { + TEST_API void operator()(const DeviceContext& context, + const phi::SelectedRows& input1, + const phi::SelectedRows& input2, + phi::SelectedRows* output); }; template struct SelectedRowsAddTensor { - void operator()(const DeviceContext& context, - const phi::SelectedRows& input1, - const phi::DenseTensor& input2, - phi::DenseTensor* output); + TEST_API void operator()(const DeviceContext& context, + const phi::SelectedRows& input1, + const phi::DenseTensor& input2, + phi::DenseTensor* output); }; // input2 = input1 + input2 template struct SelectedRowsAddTo { - void operator()(const DeviceContext& context, - const phi::SelectedRows& input1, - const int64_t input2_offset, - phi::SelectedRows* input2); + TEST_API void operator()(const DeviceContext& context, + const phi::SelectedRows& input1, + const int64_t input2_offset, + phi::SelectedRows* input2); }; // input2 = [all input in input1] + input2 template struct SelectedRowsSumTo { - void operator()(const DeviceContext& context, - const std::vector& input1, - const std::vector& input2_offsets, - phi::SelectedRows* input2); + TEST_API void operator()(const DeviceContext& context, + const std::vector& input1, + const std::vector& input2_offsets, + phi::SelectedRows* input2); }; // FIXME: The result of SelectedRowsAddToTensor maybe non deterministic, @@ -71,9 +71,9 @@ struct SelectedRowsSumTo { // input2 = input1 + input2 template struct SelectedRowsAddToTensor { - void operator()(const DeviceContext& context, - const phi::SelectedRows& input1, - phi::DenseTensor* input2); + TEST_API void operator()(const DeviceContext& context, + const phi::SelectedRows& input1, + phi::DenseTensor* input2); }; namespace scatter { @@ -85,20 +85,20 @@ struct MergeAdd { phi::SelectedRows operator()(const DeviceContext& context, const phi::SelectedRows& input, const bool sorted_result = false); - void operator()(const DeviceContext& context, - const phi::SelectedRows& input, - phi::SelectedRows* output, - const bool sorted_result = false); - void operator()(const DeviceContext& context, - const std::vector& inputs, - phi::SelectedRows* output, - const bool sorted_result = false); + TEST_API void operator()(const DeviceContext& context, + const phi::SelectedRows& input, + phi::SelectedRows* output, + const bool sorted_result = false); + TEST_API void operator()(const DeviceContext& context, + const std::vector& inputs, + phi::SelectedRows* output, + const bool sorted_result = false); }; template struct MergeAverage { - phi::SelectedRows operator()(const DeviceContext& context, - const phi::SelectedRows& input); + TEST_API phi::SelectedRows operator()(const DeviceContext& context, + const phi::SelectedRows& input); void operator()(const DeviceContext& context, const phi::SelectedRows& input, phi::SelectedRows* output); diff --git a/paddle/phi/kernels/funcs/vol2col.cc b/paddle/phi/kernels/funcs/vol2col.cc index 94acac28619b8..19d852b253d7b 100644 --- a/paddle/phi/kernels/funcs/vol2col.cc +++ b/paddle/phi/kernels/funcs/vol2col.cc @@ -29,13 +29,13 @@ namespace funcs { template class Vol2ColFunctor { public: - void operator()(const phi::CPUContext& context UNUSED, - const phi::DenseTensor& vol, - const std::vector& dilations, - const std::vector& strides, - const std::vector& paddings, - phi::DenseTensor* col, - const DataLayout data_layout) const { + TEST_API void operator()(const phi::CPUContext& context UNUSED, + const phi::DenseTensor& vol, + const std::vector& dilations, + const std::vector& strides, + const std::vector& paddings, + phi::DenseTensor* col, + const DataLayout data_layout) const { PADDLE_ENFORCE_EQ(vol.dims().size(), 4, phi::errors::InvalidArgument( @@ -155,13 +155,13 @@ class Vol2ColFunctor { template class Col2VolFunctor { public: - void operator()(const phi::CPUContext& context UNUSED, - const phi::DenseTensor& col, - const std::vector& dilations, - const std::vector& strides, - const std::vector& paddings, - phi::DenseTensor* vol, - const DataLayout data_layout) const { + TEST_API void operator()(const phi::CPUContext& context UNUSED, + const phi::DenseTensor& col, + const std::vector& dilations, + const std::vector& strides, + const std::vector& paddings, + phi::DenseTensor* vol, + const DataLayout data_layout) const { PADDLE_ENFORCE_EQ(vol->dims().size(), 4, phi::errors::InvalidArgument( diff --git a/paddle/phi/kernels/funcs/vol2col.h b/paddle/phi/kernels/funcs/vol2col.h index bd909927952d0..ab93a67b3aed4 100644 --- a/paddle/phi/kernels/funcs/vol2col.h +++ b/paddle/phi/kernels/funcs/vol2col.h @@ -69,25 +69,27 @@ using DataLayout = phi::DataLayout; template class Vol2ColFunctor { public: - void operator()(const DeviceContext& context, - const phi::DenseTensor& vol, - const std::vector& dilations, - const std::vector& strides, - const std::vector& paddings, - phi::DenseTensor* col, - const DataLayout data_layout = DataLayout::kNCHW) const; + TEST_API void operator()( + const DeviceContext& context, + const phi::DenseTensor& vol, + const std::vector& dilations, + const std::vector& strides, + const std::vector& paddings, + phi::DenseTensor* col, + const DataLayout data_layout = DataLayout::kNCHW) const; }; template class Col2VolFunctor { public: - void operator()(const DeviceContext& context, - const phi::DenseTensor& col, - const std::vector& dilations, - const std::vector& strides, - const std::vector& paddings, - phi::DenseTensor* vol, - const DataLayout data_layout = DataLayout::kNCHW) const; + TEST_API void operator()( + const DeviceContext& context, + const phi::DenseTensor& col, + const std::vector& dilations, + const std::vector& strides, + const std::vector& paddings, + phi::DenseTensor* vol, + const DataLayout data_layout = DataLayout::kNCHW) const; }; } // namespace funcs diff --git a/test/cpp/fluid/math/CMakeLists.txt b/test/cpp/fluid/math/CMakeLists.txt index 46d70de268799..ba1fe83ffb721 100644 --- a/test/cpp/fluid/math/CMakeLists.txt +++ b/test/cpp/fluid/math/CMakeLists.txt @@ -1,19 +1,8 @@ -cc_test( - selected_rows_functor_test - SRCS selected_rows_functor_test.cc - DEPS allocator phi common) -cc_test( - im2col_test - SRCS im2col_test.cc - DEPS phi common) -cc_test( - vol2col_test - SRCS vol2col_test.cc - DEPS phi common) -cc_test( - beam_search_test - SRCS beam_search_test.cc - DEPS beam_search) +paddle_test(selected_rows_functor_test SRCS selected_rows_functor_test.cc DEPS + common allocator) +paddle_test(im2col_test SRCS im2col_test.cc DEPS common phi) +paddle_test(vol2col_test SRCS vol2col_test.cc DEPS common) +paddle_test(beam_search_test SRCS beam_search_test.cc) if(WITH_GPU) nv_test( selected_rows_functor_gpu_test @@ -26,10 +15,7 @@ if(WITH_ROCM) SRCS selected_rows_functor_test.cu.cc DEPS phi common) endif() -cc_test( - concat_test - SRCS concat_test.cc - DEPS concat_and_split) +paddle_test(concat_test SRCS concat_test.cc) if(WITH_TESTING AND TEST im2col_test) set_tests_properties(im2col_test PROPERTIES TIMEOUT 120)