From 18c08f84715ae671868eac7db287f3a4b0a243ff Mon Sep 17 00:00:00 2001 From: xiongkun Date: Wed, 13 Sep 2023 06:28:21 +0000 Subject: [PATCH] merge and solve conflict --- .../eager/to_static/run_program_op_node.h | 2 +- paddle/fluid/pybind/ir.cc | 8 +++--- paddle/fluid/pybind/op_function_common.cc | 2 +- test/ir/new_ir/test_new_ir_to_static.py | 26 ------------------- 4 files changed, 6 insertions(+), 32 deletions(-) diff --git a/paddle/fluid/eager/to_static/run_program_op_node.h b/paddle/fluid/eager/to_static/run_program_op_node.h index 1167f175e3fcb..8f6f8cbbc22fc 100644 --- a/paddle/fluid/eager/to_static/run_program_op_node.h +++ b/paddle/fluid/eager/to_static/run_program_op_node.h @@ -187,7 +187,7 @@ static auto GetNameFromValue(const ::pir::Block *block, if (op->name() == "pd_op.data") { name = op->attributes().at("name").dyn_cast().AsString(); - value2name[op->results()[0].value_impl()] = name; + value2name[op->results()[0].Value::impl()] = name; } else if (op->name() == "builtin.set_parameter") { name = op->attributes() .at("parameter_name") diff --git a/paddle/fluid/pybind/ir.cc b/paddle/fluid/pybind/ir.cc index 13c23663027df..d6ad957e44959 100644 --- a/paddle/fluid/pybind/ir.cc +++ b/paddle/fluid/pybind/ir.cc @@ -565,7 +565,7 @@ Operation *BuildOpFrom( cloned_op->results().begin(), std::back_inserter(tmp), // NOLINT, just a placeholder. [&value_map](const OpResult &a, const OpResult &b) { // NOLINT - value_map[a.value_impl()] = b.value_impl(); + value_map[a.Value::impl()] = b.Value::impl(); return 1; }); return cloned_op; @@ -623,7 +623,7 @@ std::vector AnalysisMiddleVariable( forward_range, [&middle_values, &backward_inputs, &x_or_param](Operation *op) { for (auto &t : op->results()) { - auto v = Value(t.value_impl()); + auto v = Value(t.Value::impl()); if (backward_inputs.count(v) && !x_or_param.count(v)) middle_values.push_back(v); } @@ -667,7 +667,7 @@ SplitedResult ForwardBackwardSplit( auto op_result_to_value = [](const pir::OpResult &r) { if (r.impl() == nullptr) return Value(nullptr); - return Value(r.value_impl()); + return Value(r.Value::impl()); }; std::transform(op_result_forward_inputs.begin(), @@ -734,7 +734,7 @@ SplitedResult ForwardBackwardSplit( dtype, place); counter += 1; - backward_value_map[v] = op->results()[0].value_impl(); + backward_value_map[v] = op->results()[0].Value::impl(); }; auto create_output_fn_forward = [&ctx, diff --git a/paddle/fluid/pybind/op_function_common.cc b/paddle/fluid/pybind/op_function_common.cc index bac25ea4a81a6..a1e22b94ce192 100644 --- a/paddle/fluid/pybind/op_function_common.cc +++ b/paddle/fluid/pybind/op_function_common.cc @@ -864,7 +864,7 @@ void CastPyArg2AttrValues(PyObject* obj, if (opresult->impl() == nullptr) { results.emplace_back(pir::Value(nullptr)); } else { - results.emplace_back(pir::Value(opresult->value_impl())); + results.emplace_back(pir::Value(opresult->Value::impl())); } } } else { diff --git a/test/ir/new_ir/test_new_ir_to_static.py b/test/ir/new_ir/test_new_ir_to_static.py index 7bece0d5aa4d9..4c4596984b878 100644 --- a/test/ir/new_ir/test_new_ir_to_static.py +++ b/test/ir/new_ir/test_new_ir_to_static.py @@ -34,8 +34,6 @@ def func(x): x.stop_gradient = False y.stop_gradient = False ans = func(x) - print("Ans: ", ans) - print(static_func.get_concrete_program(x)[1].train_program) out = static_func(x) np.testing.assert_allclose( @@ -69,30 +67,6 @@ def func(x): ) -# class TestDy2staticNewIR2(unittest.TestCase): -# def test_basic_layer(self): -# class SimpleNet(paddle.nn.Layer): -# def __init__(self): -# super().__init__() -# self.linear = paddle.nn.Linear(10, 10) - -# def forward(self, x): -# return self.linear(x) - -# net = SimpleNet() -# x = paddle.randn((10, 10)) -# x.stop_gradient = False -# ans = net(x) -# print("Ans: ", ans) -# net = paddle.jit.to_static(net) -# print(net.forward.get_concrete_program(x)[1].train_program) -# out = net(x) - -# np.testing.assert_allclose( -# out.numpy(), ans.numpy(), rtol=1e-05, atol=1e-8 -# ) - - class TestDy2staticNewIR3(unittest.TestCase): def test_complex_layer(self): def output_pure_func(x, y):