Skip to content

【paddle_test No.27】replace parts of cc_test with paddle_test #61675

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

Merged
merged 20 commits into from
Mar 1, 2024
Merged
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
7 changes: 4 additions & 3 deletions paddle/fluid/framework/shape_inference.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ class InferShapeContext {

virtual DDim GetInputDim(const std::string &name) const = 0;
virtual std::vector<DDim> GetInputsDim(const std::string &name) const = 0;
virtual std::vector<DDim> GetReaderDims(const std::string &name) const;
TEST_API virtual std::vector<DDim> GetReaderDims(
const std::string &name) const;

virtual void SetOutputDim(const std::string &name, const DDim &dim) = 0;
virtual void SetOutputsDim(const std::string &name,
const std::vector<DDim> &dims) = 0;
virtual void SetReaderDims(const std::string &name,
const std::vector<DDim> &dims);
TEST_API virtual void SetReaderDims(const std::string &name,
const std::vector<DDim> &dims);
virtual std::string GetInputNameByIdx(size_t idx) const = 0;
virtual std::string GetOutputNameByIdx(size_t idx) const = 0;
virtual AttrReader Attrs() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/imperative/var_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void InitializeVariable(paddle::framework::Variable* var,
template <typename VarType>
const paddle::platform::Place& GetPlace(const std::shared_ptr<VarType>& var);
template <typename VarType>
const std::string& GetNameFromVar(std::shared_ptr<VarType> var);
TEST_API const std::string& GetNameFromVar(std::shared_ptr<VarType> var);

template <typename VarType>
bool CheckCachedKey(std::shared_ptr<VarType> tensor, const phi::KernelKey& key);
Expand Down
13 changes: 7 additions & 6 deletions paddle/fluid/memory/allocation/allocator_facade.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ class AllocatorFacade {
const AllocatorFacade& operator=(const AllocatorFacade& o) = delete;
~AllocatorFacade();

static AllocatorFacade& Instance();
TEST_API static AllocatorFacade& Instance();

AllocatorFacadePrivate* GetPrivate() const;

const std::shared_ptr<Allocator>& GetAllocator(const platform::Place& place);
TEST_API const std::shared_ptr<Allocator>& GetAllocator(
const platform::Place& place);

void* GetBasePtr(const std::shared_ptr<Allocation>& allocation);

Expand Down Expand Up @@ -88,8 +89,8 @@ class AllocatorFacade {
void RecordStream(std::shared_ptr<Allocation> allocation, gpuStream_t stream);
void EraseStream(std::shared_ptr<Allocation> allocation, gpuStream_t stream);

const std::shared_ptr<Allocator>& GetAllocator(const platform::Place& place,
gpuStream_t stream);
TEST_API const std::shared_ptr<Allocator>& GetAllocator(
const platform::Place& place, gpuStream_t stream);
gpuStream_t GetStream(const std::shared_ptr<Allocation>& allocation) const;
void SetDefaultStream(const platform::CUDAPlace& place, gpuStream_t stream);
#endif
Expand All @@ -104,8 +105,8 @@ class AllocatorFacade {
phi::stream::stream_t stream);
void RecordStream(std::shared_ptr<Allocation> allocation,
phi::stream::stream_t stream);
const std::shared_ptr<Allocator>& GetAllocator(const platform::Place& place,
phi::stream::stream_t stream);
TEST_API const std::shared_ptr<Allocator>& GetAllocator(
const platform::Place& place, phi::stream::stream_t stream);
phi::stream::stream_t GetStream(
const std::shared_ptr<Allocation>& allocation) const;
void SetDefaultStream(const platform::CustomPlace& place,
Expand Down
34 changes: 17 additions & 17 deletions paddle/fluid/memory/memcpy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,12 @@ void Copy<phi::Place, phi::Place>(phi::Place dst_place,

// NOTE: only for (CPUPlace, CUDAPlace and CUDAPinnedPlace) -> (CPUPlace).
template <>
void Copy<phi::CPUPlace, phi::Place>(phi::CPUPlace dst_place,
void* dst,
phi::Place src_place,
const void* src,
size_t num,
void* stream) {
TEST_API void Copy<phi::CPUPlace, phi::Place>(phi::CPUPlace dst_place,
void* dst,
phi::Place src_place,
const void* src,
size_t num,
void* stream) {
Copy(phi::Place(dst_place.GetType()), dst, src_place, src, num, stream);
}

Expand Down Expand Up @@ -835,11 +835,11 @@ TEST_API void Copy<phi::Place, phi::CPUPlace>(phi::Place dst_place,

// NOTE: Only for (CPUPlace and PinnedPlace) -> (CPUPlace).
template <>
void Copy<phi::CPUPlace, phi::Place>(phi::CPUPlace dst_place,
void* dst,
phi::Place src_place,
const void* src,
size_t num) {
TEST_API void Copy<phi::CPUPlace, phi::Place>(phi::CPUPlace dst_place,
void* dst,
phi::Place src_place,
const void* src,
size_t num) {
Copy(phi::Place(dst_place.GetType()), dst, src_place, src, num);
}

Expand Down Expand Up @@ -872,12 +872,12 @@ void Copy<phi::Place, phi::Place>(phi::Place dst_place,
}

template <>
void Copy<phi::CPUPlace, phi::Place>(phi::CPUPlace dst_place,
void* dst,
phi::Place src_place,
const void* src,
size_t num,
void* stream) {
TEST_API void Copy<phi::CPUPlace, phi::Place>(phi::CPUPlace dst_place,
void* dst,
phi::Place src_place,
const void* src,
size_t num,
void* stream) {
Copy(phi::Place(dst_place.GetType()), dst, src_place, src, num, stream);
}

Expand Down
4 changes: 2 additions & 2 deletions 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 All @@ -51,7 +51,7 @@ void Copy(DstPlace, void* dst, SrcPlace, const void* src, size_t num);
*
*/
template <typename DstPlace, typename SrcPlace>
void Copy(
TEST_API void Copy(
DstPlace, void* dst, SrcPlace, const void* src, size_t num, void* stream);
} // namespace memory
} // namespace paddle
7 changes: 4 additions & 3 deletions paddle/fluid/operators/common_infer_shape_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ framework::DDim BroadcastTwoDims(const framework::DDim& x_dims,
int axis = -1);
}
// shape input(0) -> output(0) without change.
void UnaryOpUnchangedInferShape(framework::InferShapeContext* ctx);
TEST_API void UnaryOpUnchangedInferShape(framework::InferShapeContext* ctx);
// shape input(0) -> output(0) without change, check if axis in range [-Rank(x),
// Rank(x)-1]
void UnaryOpUnchangedInferShapeCheckAxis(framework::InferShapeContext* ctx);
TEST_API void UnaryOpUnchangedInferShapeCheckAxis(
framework::InferShapeContext* ctx);
// broadcast input(0) and input(1) -> output(0)
void BinaryOpBroadcastInferShape(framework::InferShapeContext* ctx);
TEST_API void BinaryOpBroadcastInferShape(framework::InferShapeContext* ctx);

} // namespace operators
} // namespace paddle
3 changes: 2 additions & 1 deletion paddle/phi/core/selected_rows.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class SelectedRows : public TensorBase,
*
*/
public:
SelectedRows(const std::vector<int64_t>& rows, const int64_t& height);
TEST_API SelectedRows(const std::vector<int64_t>& rows,
const int64_t& height);

TEST_API SelectedRows();

Expand Down
60 changes: 13 additions & 47 deletions test/cpp/fluid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ endif()
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} executor)

if(WITH_XPU)
cc_test(
beam_search_decode_op_xpu_test
SRCS beam_search_decode_op_xpu_test.cc
DEPS lod_tensor)
paddle_test(beam_search_decode_op_xpu_test SRCS
beam_search_decode_op_xpu_test.cc)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} xpulib)
endif()

cc_test(
nv_test(
test_common_infer_shape_functions
SRCS test_common_infer_shape_functions.cc
DEPS common_infer_shape_functions
Expand All @@ -50,30 +48,12 @@ cc_test(
phi
common
generated_static_op)
cc_test(
gather_test
SRCS gather_test.cc
DEPS tensor)
cc_test(
assign_op_test
SRCS assign_op_test.cc
DEPS generated_static_op)
cc_test(
scatter_test
SRCS scatter_test.cc
DEPS tensor phi common)
cc_test(
beam_search_decode_op_test
SRCS beam_search_decode_op_test.cc
DEPS lod_tensor)
cc_test(
save_load_op_test
SRCS save_load_op_test.cc
DEPS save_op load_op)
cc_test(
save_load_combine_op_test
SRCS save_load_combine_op_test.cc
DEPS save_combine_op load_combine_op)
paddle_test(gather_test SRCS gather_test.cc)
paddle_test(assign_op_test SRCS assign_op_test.cc)
paddle_test(scatter_test SRCS scatter_test.cc DEPS common)
paddle_test(beam_search_decode_op_test SRCS beam_search_decode_op_test.cc)
paddle_test(save_load_op_test SRCS save_load_op_test.cc)
paddle_test(save_load_combine_op_test SRCS save_load_combine_op_test.cc)
if(WITH_CINN)
set(CINN_DEPS python)
endif()
Expand Down Expand Up @@ -108,15 +88,10 @@ elseif(WITH_ROCM)
test_leaky_relu_grad_grad_functor.cu
DEPS tensor device_context eigen3)
else()
cc_test(
test_leaky_relu_grad_grad_functor
SRCS test_leaky_relu_grad_grad_functor.cc
DEPS tensor device_context eigen3)
paddle_test(test_leaky_relu_grad_grad_functor SRCS
test_leaky_relu_grad_grad_functor.cc)
endif()
cc_test(
share_buffer_op_cpp_test
SRCS share_buffer_op_test.cc
DEPS lod_tensor device_context generated_static_op)
paddle_test(share_buffer_op_cpp_test SRCS share_buffer_op_test.cc)

if(WITH_CINN)
paddle_test(op_debug_string_test SRCS op_debug_string_test.cc)
Expand All @@ -125,16 +100,7 @@ else()
endif()

if(WITH_GPU)
cc_test(
copy_cross_scope_test
SRCS copy_cross_scope_test.cc
DEPS op_registry
copy_cross_scope_op
scope
device_context
enforce
executor
common)
paddle_test(copy_cross_scope_test SRCS copy_cross_scope_test.cc)
endif()

if(WITH_ONNXRUNTIME AND WIN32)
Expand Down
2 changes: 0 additions & 2 deletions test/cpp/fluid/copy_cross_scope_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ limitations under the License. */
namespace f = paddle::framework;
namespace p = paddle::platform;

USE_NO_KERNEL_OP(copy_cross_scope);

template <typename T>
void Compare1(f::Scope* scope,
const p::DeviceContext& ctx,
Expand Down
5 changes: 0 additions & 5 deletions test/cpp/fluid/save_load_combine_op_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ limitations under the License. */
#include "paddle/fluid/platform/float16.h"
#include "paddle/phi/core/kernel_registry.h"

USE_OP_ITSELF(save_combine);
USE_OP_ITSELF(load_combine);
PD_DECLARE_KERNEL(save_combine_tensor, CPU, ALL_LAYOUT);
PD_DECLARE_KERNEL(load_combine, CPU, ALL_LAYOUT);

template <typename T, typename U>
T* CreateForSaveCombineOp(int x,
int y,
Expand Down
4 changes: 0 additions & 4 deletions test/cpp/fluid/save_load_op_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ limitations under the License. */
#include "paddle/fluid/platform/float16.h"
#include "paddle/phi/core/kernel_registry.h"

USE_OP_ITSELF(save);
PD_DECLARE_KERNEL(save, CPU, ALL_LAYOUT);
PD_DECLARE_KERNEL(save_sr, CPU, ALL_LAYOUT);
PD_DECLARE_KERNEL(cast, CPU, ALL_LAYOUT);
USE_OP_ITSELF(load);
PD_DECLARE_KERNEL(load, CPU, ALL_LAYOUT);
PD_DECLARE_KERNEL(load_sr, CPU, ALL_LAYOUT);

TEST(SaveLoadOp, CPU) {
Expand Down
8 changes: 0 additions & 8 deletions test/cpp/fluid/share_buffer_op_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
#include "paddle/fluid/platform/place.h"
#include "paddle/phi/core/kernel_registry.h"

USE_OP_ITSELF(share_buffer);

PD_DECLARE_KERNEL(share_buffer, CPU, ALL_LAYOUT);

#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PD_DECLARE_KERNEL(share_buffer, GPU, ALL_LAYOUT);
#endif

namespace paddle {
namespace framework {

Expand Down