diff --git a/paddle/fluid/pybind/ir.cc b/paddle/fluid/pybind/ir.cc index b7e7de4ee6b90ef67bd8408398cb59167182689a..1cd1be8e8d9da8c6a82ceefc3284084bfeda0252 100644 --- a/paddle/fluid/pybind/ir.cc +++ b/paddle/fluid/pybind/ir.cc @@ -58,7 +58,6 @@ void BindGraph(py::module *m) { .def("get_float", &Graph::Get) .def("get_double", &Graph::Get) .def("get_string", &Graph::Get) - .def("get_program", &Graph::Get) .def("get_marked_nodes", &Graph::Get>) .def("set", [](Graph &self, const std::string &attr_name, int attr) { return self.Set(attr_name, new int(attr)); }) @@ -75,11 +74,6 @@ void BindGraph(py::module *m) { [](Graph &self, const std::string &attr_name, double attr) { return self.Set(attr_name, new double(attr)); }) - .def("set", - [](Graph &self, const std::string &attr_name, - const ProgramDesc &attr) { - return self.Set(attr_name, new ProgramDesc(attr)); - }) .def("set", [](Graph &self, const std::string &attr_name, const std::unordered_set &attr) { diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index c470483756659b55329c022e0c43002182db815b..e63a3b687153b98f3a7735c6e3d9be5136c278c6 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -788,8 +788,7 @@ All parameter, weight, gradient are variables in Paddle. m.def("disable_profiler", platform::DisableProfiler); m.def("is_profiler_enabled", platform::IsProfileEnabled); m.def("reset_profiler", platform::ResetProfiler); - m.def("get_pass", [](const py::bytes &binary_str) { - std::string pass_type(binary_str); + m.def("get_pass", [](const std::string &pass_type) { auto pass = framework::ir::PassRegistry::Instance().Get(pass_type); return std::shared_ptr(std::move(pass)); }); @@ -797,10 +796,9 @@ All parameter, weight, gradient are variables in Paddle. py::class_> pass(m, "Pass"); pass.def(py::init()) .def("has", &ir::Pass::Has) - .def("set", - [](ir::Pass &self, const std::string &attr_name, - const ProgramDesc &attr) { - return self.Set(attr_name, new ProgramDesc(attr)); + .def("set_not_owned", + [](ir::Pass &self, const std::string &attr_name, ProgramDesc &attr) { + self.SetNotOwned(attr_name, &attr); }) .def( "set", @@ -809,7 +807,6 @@ All parameter, weight, gradient are variables in Paddle. }) .def("set", [](ir::Pass &self, const std::string &name, int val) { self.Set(name, new int(val)); }) - .def("get_program", &ir::Pass::Get) .def("type", &ir::Pass::Type) .def("apply", [](ir::Pass &self, std::shared_ptr graph) { std::unique_ptr origin_graph(graph.get()); diff --git a/python/paddle/fluid/contrib/slim/tests/test_quantization_pass.py b/python/paddle/fluid/contrib/slim/tests/test_quantization_pass.py index a8d750724641875215702c9b139adfda0fe17d7d..845db3ebb8c6582e5446153ae75c1e2865acc3a5 100644 --- a/python/paddle/fluid/contrib/slim/tests/test_quantization_pass.py +++ b/python/paddle/fluid/contrib/slim/tests/test_quantization_pass.py @@ -248,8 +248,8 @@ class TestQuantizationFreezePass(unittest.TestCase): quantized_main_program = main_graph.to_program() quantized_test_program = test_graph.to_program() - iters = 5 - batch_size = 8 + iters = 10 + batch_size = 128 train_reader = paddle.batch( paddle.reader.shuffle( diff --git a/python/paddle/fluid/contrib/tests/test_quantize_transpiler.py b/python/paddle/fluid/contrib/tests/test_quantize_transpiler.py index ade2a388f23d9ea5ddf34fe2c1ac29df7e25effc..8d2bd79e048ecd2e4c55b5fd879915a5aa28e040 100644 --- a/python/paddle/fluid/contrib/tests/test_quantize_transpiler.py +++ b/python/paddle/fluid/contrib/tests/test_quantize_transpiler.py @@ -204,7 +204,7 @@ class TestQuantizeTranspiler(unittest.TestCase): build_program(test_program, startup, True) test_program = test_program.clone(for_test=True) - quant_type = 'abs_max' + quant_type = 'range_abs_max' quant_transpiler = QuantizeTranspiler( activation_quantize_type=quant_type) quant_transpiler.training_transpile(main, startup) diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 5f121c63f814dcec9f5ade8aeb595aa9a2d21a2f..1b4b7f18e2479885bdca4b07b8004185c50054b1 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -1683,9 +1683,9 @@ class IrGraph(object): def to_program(self): convert_pass = core.get_pass('graph_to_program_pass') - convert_pass.set('program', Program().desc) + desc = core.ProgramDesc() + convert_pass.set_not_owned('program', desc) convert_pass.apply(self.graph) - desc = convert_pass.get_program('program') program = Program._construct_from_desc(desc) return program