Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【paddle_test No.18】replace cc_test with paddle_test #61673

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions paddle/fluid/operators/math/beam_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ namespace math {
template <typename T>
class BeamSearchFunctor<phi::CPUContext, T> {
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];

Expand Down
24 changes: 12 additions & 12 deletions paddle/fluid/operators/math/beam_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions paddle/fluid/operators/math/concat_and_split.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ namespace math {
* [5,6]]
*/
template <typename DeviceContext, typename T>
class ConcatFunctor {
class TEST_API ConcatFunctor {
public:
void operator()(const DeviceContext& context,
const std::vector<phi::DenseTensor>& input,
int axis,
phi::DenseTensor* output);
TEST_API void operator()(const DeviceContext& context,
const std::vector<phi::DenseTensor>& input,
int axis,
phi::DenseTensor* output);
};

/*
Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/backends/dynload/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include <string>
#include "paddle/utils/test_macros.h"

#define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h

Expand Down Expand Up @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions paddle/phi/kernels/funcs/im2col.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,25 @@ enum class ColFormat { kCFO = 0, kOCF = 1 };
template <ColFormat Format, typename DeviceContext, typename T>
class Im2ColFunctor {
public:
void operator()(const DeviceContext& context,
const phi::DenseTensor& im,
const std::vector<int>& dilation,
const std::vector<int>& stride,
const std::vector<int>& padding,
phi::DenseTensor* col,
const DataLayout data_layout = DataLayout::kNCHW);
TEST_API void operator()(const DeviceContext& context,
const phi::DenseTensor& im,
const std::vector<int>& dilation,
const std::vector<int>& stride,
const std::vector<int>& padding,
phi::DenseTensor* col,
const DataLayout data_layout = DataLayout::kNCHW);
};

template <ColFormat Format, typename DeviceContext, typename T>
class Col2ImFunctor {
public:
void operator()(const DeviceContext& context,
const phi::DenseTensor& col,
const std::vector<int>& dilation,
const std::vector<int>& stride,
const std::vector<int>& padding,
phi::DenseTensor* im,
const DataLayout data_layout = DataLayout::kNCHW);
TEST_API void operator()(const DeviceContext& context,
const phi::DenseTensor& col,
const std::vector<int>& dilation,
const std::vector<int>& stride,
const std::vector<int>& padding,
phi::DenseTensor* im,
const DataLayout data_layout = DataLayout::kNCHW);
};

} // namespace funcs
Expand Down
6 changes: 3 additions & 3 deletions paddle/phi/kernels/funcs/math_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ struct Transpose {

template <typename DeviceContext, typename T>
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
Expand Down
60 changes: 30 additions & 30 deletions paddle/phi/kernels/funcs/selected_rows_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,47 +33,47 @@ namespace funcs {
// SelectedRows + SelectedRows will simply concat value and rows.
// The real computation happens in dealing with LoDTensor.
template <typename DeviceContext, typename T>
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 <typename DeviceContext, typename T>
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 <typename DeviceContext, typename T>
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 <typename DeviceContext, typename T>
struct SelectedRowsSumTo {
void operator()(const DeviceContext& context,
const std::vector<phi::SelectedRows*>& input1,
const std::vector<int64_t>& input2_offsets,
phi::SelectedRows* input2);
TEST_API void operator()(const DeviceContext& context,
const std::vector<phi::SelectedRows*>& input1,
const std::vector<int64_t>& input2_offsets,
phi::SelectedRows* input2);
};

// FIXME: The result of SelectedRowsAddToTensor maybe non deterministic,
// because it uses CudaAtomicAdd.
// input2 = input1 + input2
template <typename DeviceContext, typename T>
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 {
Expand All @@ -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<const phi::SelectedRows*>& 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<const phi::SelectedRows*>& inputs,
phi::SelectedRows* output,
const bool sorted_result = false);
};

template <typename DeviceContext, typename T>
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);
Expand Down
28 changes: 14 additions & 14 deletions paddle/phi/kernels/funcs/vol2col.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ namespace funcs {
template <class T>
class Vol2ColFunctor<phi::CPUContext, T> {
public:
void operator()(const phi::CPUContext& context UNUSED,
const phi::DenseTensor& vol,
const std::vector<int>& dilations,
const std::vector<int>& strides,
const std::vector<int>& 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<int>& dilations,
const std::vector<int>& strides,
const std::vector<int>& paddings,
phi::DenseTensor* col,
const DataLayout data_layout) const {
PADDLE_ENFORCE_EQ(vol.dims().size(),
4,
phi::errors::InvalidArgument(
Expand Down Expand Up @@ -155,13 +155,13 @@ class Vol2ColFunctor<phi::CPUContext, T> {
template <class T>
class Col2VolFunctor<phi::CPUContext, T> {
public:
void operator()(const phi::CPUContext& context UNUSED,
const phi::DenseTensor& col,
const std::vector<int>& dilations,
const std::vector<int>& strides,
const std::vector<int>& 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<int>& dilations,
const std::vector<int>& strides,
const std::vector<int>& paddings,
phi::DenseTensor* vol,
const DataLayout data_layout) const {
PADDLE_ENFORCE_EQ(vol->dims().size(),
4,
phi::errors::InvalidArgument(
Expand Down
30 changes: 16 additions & 14 deletions paddle/phi/kernels/funcs/vol2col.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,27 @@ using DataLayout = phi::DataLayout;
template <typename DeviceContext, typename T>
class Vol2ColFunctor {
public:
void operator()(const DeviceContext& context,
const phi::DenseTensor& vol,
const std::vector<int>& dilations,
const std::vector<int>& strides,
const std::vector<int>& 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<int>& dilations,
const std::vector<int>& strides,
const std::vector<int>& paddings,
phi::DenseTensor* col,
const DataLayout data_layout = DataLayout::kNCHW) const;
};

template <typename DeviceContext, typename T>
class Col2VolFunctor {
public:
void operator()(const DeviceContext& context,
const phi::DenseTensor& col,
const std::vector<int>& dilations,
const std::vector<int>& strides,
const std::vector<int>& 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<int>& dilations,
const std::vector<int>& strides,
const std::vector<int>& paddings,
phi::DenseTensor* vol,
const DataLayout data_layout = DataLayout::kNCHW) const;
};

} // namespace funcs
Expand Down
26 changes: 6 additions & 20 deletions test/cpp/fluid/math/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down