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.9】replace cc_test with paddle_test #61981

Closed
wants to merge 8 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
4 changes: 2 additions & 2 deletions paddle/phi/common/scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ void CopyScalar(const ScalarBase<T1>& src, ScalarBase<T2>* dst) {
}

using Scalar = paddle::experimental::ScalarBase<Tensor>;
bool operator==(const Scalar& lhs, const Scalar& rhs);
TEST_API bool operator==(const Scalar& lhs, const Scalar& rhs);

std::ostream& operator<<(std::ostream& os, const Scalar& s);
TEST_API std::ostream& operator<<(std::ostream& os, const Scalar& s);

template <typename T>
std::vector<T> ExtractPlainVector(
Expand Down
21 changes: 21 additions & 0 deletions paddle/phi/kernels/full_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ void FullBatchSizeLikeKernel(const Context& dev_ctx,
FullLikeKernel<T, Context>(dev_ctx, x, val, dtype, out);
}

template <typename T, typename Context>
void Full(const Context& dev_ctx,
const IntArray& shape,
const Scalar& val,
DenseTensor* out) {
FullKernel<T, Context>(
dev_ctx, shape, val, phi::CppTypeToDataType<T>::Type(), out);
}

template <typename T, typename Context>
DenseTensor Full(const Context& dev_ctx,
const IntArray& shape,
const Scalar& val) {
DenseTensor dense_out;
MetaTensor meta_out(&dense_out);
DataType dtype = phi::CppTypeToDataType<T>::Type();
CreateInferMeta(shape, dtype, &meta_out);
FullKernel<T, Context>(dev_ctx, shape, val, dtype, &dense_out);
return dense_out;
}

} // namespace phi

PD_REGISTER_KERNEL(full_batch_size_like,
Expand Down
24 changes: 7 additions & 17 deletions paddle/phi/kernels/full_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
namespace phi {

template <typename T, typename Context>
void FullKernel(const Context& dev_ctx,
const IntArray& shape,
const Scalar& val,
DataType dtype,
DenseTensor* out);
TEST_API void FullKernel(const Context& dev_ctx,
const IntArray& shape,
const Scalar& val,
DataType dtype,
DenseTensor* out);

template <typename T, typename Context>
void FullWithTensorKernel(const Context& dev_ctx,
Expand Down Expand Up @@ -61,22 +61,12 @@ template <typename T, typename Context>
void Full(const Context& dev_ctx,
const IntArray& shape,
const Scalar& val,
DenseTensor* out) {
FullKernel<T, Context>(
dev_ctx, shape, val, phi::CppTypeToDataType<T>::Type(), out);
}
DenseTensor* out);

template <typename T, typename Context>
DenseTensor Full(const Context& dev_ctx,
const IntArray& shape,
const Scalar& val) {
DenseTensor dense_out;
MetaTensor meta_out(&dense_out);
DataType dtype = phi::CppTypeToDataType<T>::Type();
CreateInferMeta(shape, dtype, &meta_out);
FullKernel<T, Context>(dev_ctx, shape, val, dtype, &dense_out);
return dense_out;
}
const Scalar& val);

template <typename T, typename Context>
DenseTensor FullLike(const Context& dev_ctx,
Expand Down
32 changes: 8 additions & 24 deletions test/cpp/phi/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
cc_test(
phi_test_backend
SRCS test_backend.cc
DEPS gtest)
cc_test(
phi_test_data_layout
SRCS test_data_layout.cc
DEPS gtest)
cc_test(
phi_test_data_type
SRCS test_data_type.cc
DEPS gtest)
cc_test(
phi_test_place
SRCS test_place.cc
DEPS phi common)
cc_test(
phi_test_int_array
SRCS test_int_array.cc
DEPS phi common)
cc_test(
phi_test_scalar_cpu
SRCS test_scalar.cc
DEPS phi common)
list(APPEND kernel_cc "full_kernel.cc")

paddle_test(phi_test_backend SRCS test_backend.cc)
paddle_test(phi_test_data_layout SRCS test_data_layout.cc)
paddle_test(phi_test_data_type SRCS test_data_type.cc)
paddle_test(phi_test_place SRCS test_place.cc DEPS common)
paddle_test(phi_test_int_array SRCS test_int_array.cc DEPS common)
paddle_test(phi_test_scalar_cpu SRCS test_scalar.cc DEPS common)
if(WITH_GPU)
nv_test(
phi_test_scalar
Expand Down