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.21】replace parts of cc_test with paddle_test #61674

Merged
merged 18 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions paddle/fluid/framework/data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace paddle {
namespace framework {

TEST_API std::string DataTypeToString(const proto::VarType::Type type);
extern size_t SizeOfType(proto::VarType::Type type);
TEST_API extern size_t SizeOfType(proto::VarType::Type type);

template <typename T>
struct IsComplex : public std::false_type {};
Expand Down Expand Up @@ -123,7 +123,7 @@ _ForEachDataType_(DefineDataTypeTrait);

#undef DefineDataTypeTrait

extern proto::VarType::Type ToDataType(std::type_index type);
TEST_API extern proto::VarType::Type ToDataType(std::type_index type);
extern std::type_index ToTypeIndex(proto::VarType::Type type);

template <typename Visitor>
Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/framework/dlpack_tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class DLPackTensor {
std::remove_reference<decltype(::DLTensor::shape[0])>::type; // int64_t

// lanes is only used in CPU to enable vectorization
explicit DLPackTensor(const phi::DenseTensor& tensor, LaneType lanes = 1);
TEST_API explicit DLPackTensor(const phi::DenseTensor& tensor,
LaneType lanes = 1);

inline operator const ::DLTensor&() const { return t_; }

Expand Down
15 changes: 8 additions & 7 deletions paddle/fluid/framework/tensor_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ class PrintOptions {
PrintOptions() {}
};

void TensorToStream(std::ostream& os,
const phi::DenseTensor& tensor,
const platform::DeviceContext& dev_ctx);
void TensorFromStream(std::istream& is,
phi::DenseTensor* tensor,
const platform::DeviceContext& dev_ctx);
TEST_API void TensorToStream(std::ostream& os,
const phi::DenseTensor& tensor,
const platform::DeviceContext& dev_ctx);
TEST_API void TensorFromStream(std::istream& is,
phi::DenseTensor* tensor,
const platform::DeviceContext& dev_ctx);
void TensorFromStream(std::istream& is,
phi::DenseTensor* tensor,
const platform::DeviceContext& dev_ctx,
Expand Down Expand Up @@ -107,7 +107,8 @@ void TesnorToVector(const phi::DenseTensor& src, std::vector<T>* dst);

// convert dlpack's DLTensor to tensor

void TensorFromDLPack(const ::DLTensor& dl_tensor, phi::DenseTensor* dst);
TEST_API void TensorFromDLPack(const ::DLTensor& dl_tensor,
phi::DenseTensor* dst);
void TensorFromDLPack(const DLManagedTensor* src, phi::DenseTensor* dst);

//
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/memory/memcpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace memory {
*
*/
template <typename DstPlace, typename SrcPlace>
void Copy(DstPlace, void* dst, SrcPlace, const void* src, size_t num);
TEST_API void Copy(DstPlace, void* dst, SrcPlace, const void* src, size_t num);

/**
* \brief Copy memory from one place to another place.
Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/core/tensor_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void TensorToVector(const phi::DenseTensor& src,
const phi::DeviceContext& ctx,
std::vector<T>* dst);

phi::DenseTensor ReshapeToMatrix(const phi::DenseTensor& src, int num_col_dims);
TEST_API phi::DenseTensor ReshapeToMatrix(const phi::DenseTensor& src,
int num_col_dims);

template <typename T>
T GetValue(const phi::DenseTensor* x);
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/isfinite_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace phi {

#define DEFINE_ISFINITE_KERNEL(isfinite_kernel) \
template <typename T, typename Context> \
void isfinite_kernel( \
TEST_API void isfinite_kernel( \
const Context& ctx, const DenseTensor& x, DenseTensor* out);

DEFINE_ISFINITE_KERNEL(IsinfKernel)
Expand Down
10 changes: 5 additions & 5 deletions paddle/phi/kernels/reduce_all_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ void AllRawKernel(const Context& dev_ctx,
DenseTensor* out);

template <typename T, typename Context>
void AllKernel(const Context& dev_ctx,
const DenseTensor& x,
const std::vector<int64_t>& dims,
bool keep_dim,
DenseTensor* out);
TEST_API void AllKernel(const Context& dev_ctx,
const DenseTensor& x,
const std::vector<int64_t>& dims,
bool keep_dim,
DenseTensor* out);

} // namespace phi
10 changes: 5 additions & 5 deletions paddle/phi/kernels/reduce_any_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ void AnyRawKernel(const Context& dev_ctx,
DenseTensor* out);

template <typename T, typename Context>
void AnyKernel(const Context& dev_ctx,
const DenseTensor& x,
const std::vector<int64_t>& dims,
bool keep_dim,
DenseTensor* out);
TEST_API void AnyKernel(const Context& dev_ctx,
const DenseTensor& x,
const std::vector<int64_t>& dims,
bool keep_dim,
DenseTensor* out);

} // namespace phi
15 changes: 3 additions & 12 deletions test/cpp/fluid/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
add_subdirectory(details)

cc_test(
data_type_test
SRCS data_type_test.cc
DEPS data_type place tensor)
paddle_test(data_type_test SRCS data_type_test.cc)

cc_test(
tensor_test
SRCS tensor_test.cc
DEPS tensor isfinite_op)
paddle_test(tensor_test SRCS tensor_test.cc)
Liyulingyue marked this conversation as resolved.
Show resolved Hide resolved
if(WITH_GPU)
nv_test(
tensor_util_test
Expand All @@ -20,10 +14,7 @@ elseif(WITH_ROCM)
SRCS tensor_util_test.cc tensor_util_test.cu
DEPS tensor dlpack_tensor isfinite_op)
else()
cc_test(
tensor_util_test
SRCS tensor_util_test.cc
DEPS tensor dlpack_tensor isfinite_op)
paddle_test(tensor_util_test SRCS tensor_util_test.cc)
Liyulingyue marked this conversation as resolved.
Show resolved Hide resolved
endif()

cc_test(
Expand Down