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.5】replace cc_test with paddle_test #60834

Merged
merged 26 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
92b27d0
Update CMakeLists.txt
Liyulingyue Jan 15, 2024
23eb9d0
Update CMakeLists.txt
Liyulingyue Jan 16, 2024
7061674
Apply suggestions from code review
Liyulingyue Jan 16, 2024
777ea3a
Apply suggestions from code review
Liyulingyue Jan 17, 2024
a83e19f
Apply suggestions from code review
Liyulingyue Jan 17, 2024
5ee5f33
Update CMakeLists.txt
Liyulingyue Jan 28, 2024
d269cbe
Update CMakeLists.txt
Liyulingyue Jan 28, 2024
6b3f55d
Update CMakeLists.txt
Liyulingyue Jan 28, 2024
9ae69e5
Update CMakeLists.txt
Liyulingyue Jan 29, 2024
a496e5b
Update interpreter.h
Liyulingyue Jan 29, 2024
714eb55
Update interpretercore.h
Liyulingyue Jan 30, 2024
ea2c648
Update kernel_dialect.h
Liyulingyue Jan 30, 2024
51adc14
Update control_flow_op.h
Liyulingyue Jan 30, 2024
810636b
Update control_flow_op.h
Liyulingyue Jan 30, 2024
450c421
Update manual_op.h
Liyulingyue Jan 30, 2024
8b94c87
Merge branch 'develop' into cc5
Liyulingyue Jan 30, 2024
a673c73
Update interpretercore.h
Liyulingyue Jan 30, 2024
539fd65
Update control_flow_op.h
Liyulingyue Jan 30, 2024
5e8c41b
Update op_gen.py
Liyulingyue Jan 30, 2024
859de17
Update paddle/fluid/pir/dialect/operator/ir/control_flow_op.h
Liyulingyue Jan 31, 2024
2036a20
Update interpreter.h
Liyulingyue Jan 31, 2024
90e6c39
Update interpretercore.h
Liyulingyue Jan 31, 2024
f08e8c5
Update control_flow_op.h
Liyulingyue Jan 31, 2024
03c0fb7
Update manual_op.h
Liyulingyue Jan 31, 2024
d534ae9
Update control_flow_op.h
Liyulingyue Jan 31, 2024
0181640
Update CMakeLists.txt
Liyulingyue Jan 31, 2024
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
9 changes: 5 additions & 4 deletions paddle/cinn/frontend/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ namespace frontend {
*/
class Interpreter final {
public:
Interpreter(const std::vector<std::string>& input_names,
const std::vector<hlir::framework::shape_t>& input_shapes);
TEST_API Interpreter(
const std::vector<std::string>& input_names,
const std::vector<hlir::framework::shape_t>& input_shapes);

/**
* Load a Paddle model.
Expand All @@ -49,15 +50,15 @@ class Interpreter final {
/**
* Run the executor.
*/
void Run();
TEST_API void Run();

frontend::Program GetProgram();

hlir::framework::Tensor GetTensor(const std::string& name);

std::shared_ptr<hlir::framework::Scope> GetScope();

~Interpreter();
TEST_API ~Interpreter();

private:
class Impl;
Expand Down
30 changes: 16 additions & 14 deletions paddle/fluid/framework/new_executor/interpretercore.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,29 @@ class InterpreterCore {
Scope* scope,
const ExecutionConfig& execution_config = ExecutionConfig());
// This constructor is for New IR.
InterpreterCore(const platform::Place& place,
const std::vector<std::string>& fetch_var_names,
const ::pir::Block* ir_prog,
Scope* scope,
const ExecutionConfig& execution_config = ExecutionConfig());
~InterpreterCore();
TEST_API InterpreterCore(
const platform::Place& place,
const std::vector<std::string>& fetch_var_names,
const ::pir::Block* ir_prog,
Scope* scope,
const ExecutionConfig& execution_config = ExecutionConfig());
TEST_API ~InterpreterCore();

const InterpreterBaseImpl* Impl() const { return impl_.get(); }

paddle::framework::FetchList Run(
TEST_API paddle::framework::FetchList Run(
const std::vector<std::string>& feed_names,
const std::vector<phi::DenseTensor>& feed_tensors,
bool need_fetch = true,
bool enable_job_schedule_profiler = false,
bool switch_stream = false);

paddle::framework::FetchList Run(const std::vector<std::string>& feed_names,
bool need_fetch = true,
bool enable_job_schedule_profiler = false,
bool enable_op_profiling = false,
bool switch_stream = false);
TEST_API paddle::framework::FetchList Run(
const std::vector<std::string>& feed_names,
bool need_fetch = true,
bool enable_job_schedule_profiler = false,
bool enable_op_profiling = false,
bool switch_stream = false);

void RunProfile(const std::vector<std::string>& feed_names);

Expand All @@ -68,7 +70,7 @@ class InterpreterCore {

void SetCopyProgram(std::shared_ptr<ProgramDesc> prog);

void SetSkipGcVars(const std::set<std::string>& skip_gc_vars);
TEST_API void SetSkipGcVars(const std::set<std::string>& skip_gc_vars);

const std::set<std::string>& JitInputVars() const;

Expand All @@ -94,7 +96,7 @@ class InterpreterCore {
std::tuple<double, double> InterpreterRunTime();

// Only for debug
Variable* DebugVar(const std::string& name) const;
TEST_API Variable* DebugVar(const std::string& name) const;

private:
DISABLE_COPY_AND_ASSIGN(InterpreterCore);
Expand Down
8 changes: 8 additions & 0 deletions paddle/fluid/pir/dialect/op_generator/op_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,18 @@
'AbsOp',
'FullOp',
'UniformOp',
'ScaleOp',
'AddOp',
'Conv2dOp',
'BatchNormOp',
'FetchOp',
'MatmulOp',
'SoftmaxOp',
'ReshapeOp',
'TransposeOp',
'LessThanOp',
'AddGradOp',
'MatmulGradOp',
]

# =====================================
Expand Down
28 changes: 14 additions & 14 deletions paddle/fluid/pir/dialect/operator/ir/control_flow_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class IfOp : public pir::Op<IfOp, VjpInterface> {
pir::Value cond,
std::vector<pir::Type> &&output_types);

static void Build(pir::Builder &builder, // NOLINT
pir::OperationArgument &argument, // NOLINT
pir::Value cond,
std::unique_ptr<pir::Block> &&true_block,
std::unique_ptr<pir::Block> &&false_block);
TEST_API static void Build(pir::Builder &builder, // NOLINT
pir::OperationArgument &argument, // NOLINT
pir::Value cond,
std::unique_ptr<pir::Block> &&true_block,
std::unique_ptr<pir::Block> &&false_block);

pir::Value cond() { return operand_source(0); }
TEST_API pir::Block &true_block();
Expand Down Expand Up @@ -74,13 +74,13 @@ class WhileOp : public pir::Op<WhileOp, VjpInterface> {
static constexpr uint32_t attributes_num = 0;
static constexpr const char **attributes_name = nullptr;

static void Build(pir::Builder &builder, // NOLINT
pir::OperationArgument &argument, // NOLINT
pir::Value cond,
const std::vector<pir::Value> &inputs,
bool construct_body = true);
TEST_API static void Build(pir::Builder &builder, // NOLINT
pir::OperationArgument &argument, // NOLINT
pir::Value cond,
const std::vector<pir::Value> &inputs,
bool construct_body = true);
TEST_API pir::Block &body();
pir::Value cond();
TEST_API pir::Value cond();
const pir::Block::ArgsType &block_args() { return body().args(); }
void Print(pir::IrPrinter &printer); // NOLINT
void VerifySig();
Expand Down Expand Up @@ -122,9 +122,9 @@ class HasElementsOp : public pir::Op<HasElementsOp> {
static constexpr uint32_t attributes_num = 0;
static constexpr const char **attributes_name = nullptr;

static void Build(pir::Builder &builder, // NOLINT
pir::OperationArgument &argument, // NOLINT
pir::Value container);
TEST_API static void Build(pir::Builder &builder, // NOLINT
pir::OperationArgument &argument, // NOLINT
pir::Value container);
void VerifySig();
pir::Value input() { return operand_source(0); }
pir::Value out() { return result(0); }
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/pir/dialect/operator/ir/manual_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class AddNOp : public pir::Op<AddNOp,
static constexpr const char **attributes_name = nullptr;
static constexpr uint32_t attributes_num = 0;
static OpInfoTuple GetOpInfo();
static void Build(pir::Builder &builder, // NOLINT
pir::OperationArgument &argument, // NOLINT
pir::Value inputs);
TEST_API static void Build(pir::Builder &builder, // NOLINT
pir::OperationArgument &argument, // NOLINT
pir::Value inputs);

void VerifySig();
pir::Value inputs() { return operand_source(0); }
Expand Down
15 changes: 7 additions & 8 deletions test/cpp/pir/control_flow_dialect/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
if(NOT WITH_ROCM)
cc_test(
if_op_test
SRCS if_op_test.cc
DEPS pir op_dialect_vjp pir_transforms op_dialect gtest)
paddle_test(if_op_test SRCS if_op_test.cc)
if(WITH_ONNXRUNTIME AND WIN32)
# Copy onnxruntime for some c++ test in Windows, since the test will
# be build only in CI, so suppose the generator in Windows is Ninja.
copy_onnx(if_op_test)
endif()

cc_test(
while_op_test
SRCS while_op_test.cc
DEPS pir op_dialect_vjp pir_transforms op_dialect gtest device_event_base)
paddle_test(while_op_test SRCS while_op_test.cc)
endif()