diff --git a/python/paddle/fluid/tests/unittests/benchmark.py b/python/paddle/fluid/tests/unittests/benchmark.py index e8dcffe3ca564..3384c04889389 100644 --- a/python/paddle/fluid/tests/unittests/benchmark.py +++ b/python/paddle/fluid/tests/unittests/benchmark.py @@ -16,8 +16,7 @@ import numpy as np from eager_op_test import OpTest - -from paddle.fluid.op import Operator +from op import Operator class BenchmarkSuite(OpTest): diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/test_dgc_momentum_op.py b/python/paddle/fluid/tests/unittests/collective/fleet/test_dgc_momentum_op.py index bc4a9d7f6a87f..408209c2f9130 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/test_dgc_momentum_op.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/test_dgc_momentum_op.py @@ -18,7 +18,7 @@ from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator +from paddle.fluid.tests.unittests.op import Operator class TestDGCMomentumOp1(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/test_dgc_op.py b/python/paddle/fluid/tests/unittests/collective/fleet/test_dgc_op.py index f59d106f94b9e..31077002bd423 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/test_dgc_op.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/test_dgc_op.py @@ -18,7 +18,7 @@ from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator +from paddle.fluid.tests.unittests.op import Operator g_array_size = 102400 diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/test_recv_save_op.py b/python/paddle/fluid/tests/unittests/collective/fleet/test_recv_save_op.py index 29c6ab86523ed..2599e876b052c 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/test_recv_save_op.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/test_recv_save_op.py @@ -25,7 +25,7 @@ from paddle import fluid from paddle.fluid import core from paddle.fluid.framework import Program, program_guard -from paddle.fluid.op import Operator +from paddle.fluid.tests.unittests.op import Operator from paddle.incubate.distributed.fleet.parameter_server.mode import ( DistributedMode, ) diff --git a/python/paddle/fluid/tests/unittests/eager_op_test.py b/python/paddle/fluid/tests/unittests/eager_op_test.py index ff7757bcd681e..e824e5cdb0a63 100644 --- a/python/paddle/fluid/tests/unittests/eager_op_test.py +++ b/python/paddle/fluid/tests/unittests/eager_op_test.py @@ -23,6 +23,7 @@ from copy import copy import numpy as np +from op import Operator import paddle from paddle import fluid @@ -35,7 +36,6 @@ _current_expected_place, canonicalize_attrs, ) -from paddle.fluid.op import Operator sys.path.append(os.path.abspath(os.path.dirname(__file__))) from prim_op_test import OpTestUtils, PrimForwardChecker, PrimGradChecker diff --git a/python/paddle/fluid/op.py b/python/paddle/fluid/tests/unittests/op.py similarity index 84% rename from python/paddle/fluid/op.py rename to python/paddle/fluid/tests/unittests/op.py index f0b7cefc1b7ef..6adc9daa52a09 100644 --- a/python/paddle/fluid/op.py +++ b/python/paddle/fluid/tests/unittests/op.py @@ -14,8 +14,9 @@ import numpy as np -import paddle.fluid.core as core -import paddle.fluid.proto.framework_pb2 as framework_pb2 +from paddle.fluid import core +from paddle.fluid.proto import framework_pb2 + # NOTE: this is added to support creating a Scalar message # from a python number @@ -256,13 +257,13 @@ def __impl__(*args, **kwargs): inputs=[(var.name, var.duplicable) for var in op_proto.inputs], outputs=[(var.name, var.duplicable) for var in op_proto.outputs], attrs=[attr.name for attr in op_proto.attrs], - extra_attrs=[item for item in extra_attrs_map.keys()], + extra_attrs=list(extra_attrs_map.keys()), ) class OperatorFactory: def __init__(self): - self.op_methods = dict() + self.op_methods = {} for op_proto in get_all_op_protos(): method = create_op_creation_method(op_proto) @@ -313,70 +314,4 @@ def get_op_extra_attr_names(self, type): return self.get_op_info(type).extra_attrs -class __RecurrentOp__: - __proto__ = None - type = "recurrent" - - def __init__(self): - # cache recurrent_op's proto - if self.__proto__ is None: - for op_proto in get_all_op_protos(): - if op_proto.type == self.type: - self.__proto__ = op_proto - - def __call__(self, *args, **kwargs): - if self.type not in args and "type" not in kwargs: - kwargs["type"] = self.type - # create proto - create_method = OpDescCreationMethod(self.__proto__) - proto = create_method(*args, **kwargs) - # create rnnop - return core.RecurrentOp.create(proto.SerializeToString()) - - -class __DynamicRecurrentOp__: - __proto__ = None - type = "dynamic_recurrent" - - def __init__(self): - # cache recurrent_op's proto - if self.__proto__ is None: - for op_proto in get_all_op_protos(): - if op_proto.type == self.type: - self.__proto__ = op_proto - - def __call__(self, *args, **kwargs): - if self.type not in args and "type" not in kwargs: - kwargs["type"] = self.type - # create proto - create_method = OpDescCreationMethod(self.__proto__) - proto = create_method(*args, **kwargs) - # create rnnop - return core.DynamicRecurrentOp.create(proto.SerializeToString()) - - -class __CondOp__: - __proto__ = None - type = "cond" - - def __init__(self): - # cache recurrent_op's proto - if self.__proto__ is None: - for op_proto in get_all_op_protos(): - if op_proto.type == self.type: - self.__proto__ = op_proto - - def __call__(self, *args, **kwargs): - if self.type not in args and "type" not in kwargs: - kwargs["type"] = self.type - # create proto - create_method = OpDescCreationMethod(self.__proto__) - proto = create_method(*args, **kwargs) - # create condop - return core.CondOp.create(proto.SerializeToString()) - - Operator = OperatorFactory() # The default global factory -RecurrentOp = __RecurrentOp__() -DynamicRecurrentOp = __DynamicRecurrentOp__() -CondOp = __CondOp__() diff --git a/python/paddle/fluid/tests/unittests/test_activation_sparse_op.py b/python/paddle/fluid/tests/unittests/test_activation_sparse_op.py index 4912381cf4c77..48bf62a5947ef 100644 --- a/python/paddle/fluid/tests/unittests/test_activation_sparse_op.py +++ b/python/paddle/fluid/tests/unittests/test_activation_sparse_op.py @@ -15,10 +15,10 @@ import unittest import numpy as np +from op import Operator import paddle from paddle.fluid import core -from paddle.fluid.op import Operator class TestSparseSquareOp(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_adagrad_op.py b/python/paddle/fluid/tests/unittests/test_adagrad_op.py index 82db9c9a67da8..f90bd83490b56 100644 --- a/python/paddle/fluid/tests/unittests/test_adagrad_op.py +++ b/python/paddle/fluid/tests/unittests/test_adagrad_op.py @@ -17,10 +17,10 @@ import numpy as np from eager_op_test import OpTest +from op import Operator import paddle from paddle.fluid import core -from paddle.fluid.op import Operator def adamgrad_wrapper( diff --git a/python/paddle/fluid/tests/unittests/test_adam_op.py b/python/paddle/fluid/tests/unittests/test_adam_op.py index f8861b8445ca7..8e4428131c6c8 100644 --- a/python/paddle/fluid/tests/unittests/test_adam_op.py +++ b/python/paddle/fluid/tests/unittests/test_adam_op.py @@ -16,11 +16,11 @@ import numpy as np from eager_op_test import OpTest +from op import Operator import paddle from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator def adam_wrapper( diff --git a/python/paddle/fluid/tests/unittests/test_batch_norm_op.py b/python/paddle/fluid/tests/unittests/test_batch_norm_op.py index 173fd4881b5c4..86ffea08a2254 100644 --- a/python/paddle/fluid/tests/unittests/test_batch_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_batch_norm_op.py @@ -17,12 +17,12 @@ import numpy as np from eager_op_test import OpTest, _set_use_system_allocator +from op import Operator import paddle from paddle import fluid from paddle.fluid import Program, core, program_guard from paddle.fluid.framework import grad_var_name -from paddle.fluid.op import Operator _set_use_system_allocator(True) diff --git a/python/paddle/fluid/tests/unittests/test_beam_search_decode_op.py b/python/paddle/fluid/tests/unittests/test_beam_search_decode_op.py index 57b83f034186c..eee6832f2d254 100644 --- a/python/paddle/fluid/tests/unittests/test_beam_search_decode_op.py +++ b/python/paddle/fluid/tests/unittests/test_beam_search_decode_op.py @@ -15,9 +15,9 @@ import unittest import numpy as np +from op import Operator from paddle.fluid import core -from paddle.fluid.op import Operator class TestBeamSearchDecodeOp(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_beam_search_op.py b/python/paddle/fluid/tests/unittests/test_beam_search_op.py index 786d2887ed361..940f365bdee77 100644 --- a/python/paddle/fluid/tests/unittests/test_beam_search_op.py +++ b/python/paddle/fluid/tests/unittests/test_beam_search_op.py @@ -15,9 +15,9 @@ import unittest import numpy as np +from op import Operator from paddle.fluid import core -from paddle.fluid.op import Operator def create_tensor(scope, name, np_data): diff --git a/python/paddle/fluid/tests/unittests/test_clip_by_norm_op.py b/python/paddle/fluid/tests/unittests/test_clip_by_norm_op.py index 0e403cc2c9bdf..12c161ca9e56f 100644 --- a/python/paddle/fluid/tests/unittests/test_clip_by_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_clip_by_norm_op.py @@ -16,9 +16,9 @@ import numpy as np from eager_op_test import OpTest +from op import Operator import paddle -from paddle import fluid from paddle.fluid import core from paddle.nn import clip @@ -119,7 +119,7 @@ def check_with_place(self, place): out_selected_rows = scope.var('Out').get_selected_rows() # run clip_by_norm_op - clip_by_norm_op = fluid.op.Operator( + clip_by_norm_op = Operator( "clip_by_norm", max_norm=self.max_norm, X='X', Out='Out' ) clip_by_norm_op.run(scope, place) diff --git a/python/paddle/fluid/tests/unittests/test_data_norm_op.py b/python/paddle/fluid/tests/unittests/test_data_norm_op.py index d92d66e10da9c..9bb518bfd4f0b 100644 --- a/python/paddle/fluid/tests/unittests/test_data_norm_op.py +++ b/python/paddle/fluid/tests/unittests/test_data_norm_op.py @@ -17,11 +17,11 @@ import numpy as np from eager_op_test import OpTest +from op import Operator import paddle from paddle import fluid from paddle.fluid import Program, core, program_guard -from paddle.fluid.op import Operator def _reference_testing(x, batch_size, batch_sum, batch_square_sum, slot_dim=-1): diff --git a/python/paddle/fluid/tests/unittests/test_fake_init_op.py b/python/paddle/fluid/tests/unittests/test_fake_init_op.py index e3ca7e79dde77..30b934a7c93ce 100644 --- a/python/paddle/fluid/tests/unittests/test_fake_init_op.py +++ b/python/paddle/fluid/tests/unittests/test_fake_init_op.py @@ -14,8 +14,9 @@ import unittest +from op import Operator + from paddle.fluid import core -from paddle.fluid.op import Operator class TestFakeInitOpSelectedRows(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_fill_constant_op.py b/python/paddle/fluid/tests/unittests/test_fill_constant_op.py index 8aeb64c1a4685..a0bd1df957314 100644 --- a/python/paddle/fluid/tests/unittests/test_fill_constant_op.py +++ b/python/paddle/fluid/tests/unittests/test_fill_constant_op.py @@ -16,11 +16,11 @@ import numpy as np from eager_op_test import OpTest, convert_float_to_uint16 +from op import Operator import paddle from paddle import fluid from paddle.fluid import Program, core, program_guard -from paddle.fluid.op import Operator def fill_wrapper(shape, value=0.0): diff --git a/python/paddle/fluid/tests/unittests/test_fill_op.py b/python/paddle/fluid/tests/unittests/test_fill_op.py index 883c9541d0daf..bd7dc4dccf878 100644 --- a/python/paddle/fluid/tests/unittests/test_fill_op.py +++ b/python/paddle/fluid/tests/unittests/test_fill_op.py @@ -16,9 +16,9 @@ import numpy as np from eager_op_test import OpTest, convert_float_to_uint16 +from op import Operator from paddle.fluid import core -from paddle.fluid.op import Operator class TestFillOp1(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_ftrl_op.py b/python/paddle/fluid/tests/unittests/test_ftrl_op.py index 0926f80ccafb2..4493f428aaf68 100644 --- a/python/paddle/fluid/tests/unittests/test_ftrl_op.py +++ b/python/paddle/fluid/tests/unittests/test_ftrl_op.py @@ -16,9 +16,9 @@ import numpy as np from eager_op_test import OpTest +from op import Operator from paddle.fluid import core -from paddle.fluid.op import Operator def ftrl_step(param, grad, rows, sq_accum, lin_accum, lr, l1, l2, lr_power): diff --git a/python/paddle/fluid/tests/unittests/test_get_tensor_from_selected_rows_op.py b/python/paddle/fluid/tests/unittests/test_get_tensor_from_selected_rows_op.py index b2526a1a571a3..dbbef2ce2cc74 100644 --- a/python/paddle/fluid/tests/unittests/test_get_tensor_from_selected_rows_op.py +++ b/python/paddle/fluid/tests/unittests/test_get_tensor_from_selected_rows_op.py @@ -15,10 +15,10 @@ import unittest import numpy as np +from op import Operator import paddle from paddle.fluid import Program, core, program_guard -from paddle.fluid.op import Operator from paddle.nn import clip diff --git a/python/paddle/fluid/tests/unittests/test_lamb_op.py b/python/paddle/fluid/tests/unittests/test_lamb_op.py index 849fa956eb9bd..8455a4ebe2cf6 100644 --- a/python/paddle/fluid/tests/unittests/test_lamb_op.py +++ b/python/paddle/fluid/tests/unittests/test_lamb_op.py @@ -16,10 +16,10 @@ import numpy as np from eager_op_test import OpTest +from op import Operator import paddle from paddle.fluid import core -from paddle.fluid.op import Operator paddle.enable_static() diff --git a/python/paddle/fluid/tests/unittests/test_lookup_table_bf16_op.py b/python/paddle/fluid/tests/unittests/test_lookup_table_bf16_op.py index 8e11cbe924554..d32ccafaf3b9f 100644 --- a/python/paddle/fluid/tests/unittests/test_lookup_table_bf16_op.py +++ b/python/paddle/fluid/tests/unittests/test_lookup_table_bf16_op.py @@ -15,11 +15,11 @@ import unittest import numpy as np +from op import Operator import paddle from paddle import enable_static, fluid from paddle.fluid import core -from paddle.fluid.op import Operator from paddle.fluid.tests.unittests.eager_op_test import ( OpTest, convert_float_to_uint16, diff --git a/python/paddle/fluid/tests/unittests/test_lookup_table_op.py b/python/paddle/fluid/tests/unittests/test_lookup_table_op.py index b0d38e7a5de3c..de868db11fb1a 100644 --- a/python/paddle/fluid/tests/unittests/test_lookup_table_op.py +++ b/python/paddle/fluid/tests/unittests/test_lookup_table_op.py @@ -21,12 +21,12 @@ paddle_static_guard, skip_check_grad_ci, ) +from op import Operator import paddle import paddle.nn.functional as F from paddle import fluid from paddle.fluid import Program, core, program_guard -from paddle.fluid.op import Operator class TestLookupTableOp(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py b/python/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py index e8220ff5215ef..54e9992a13d6b 100644 --- a/python/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py +++ b/python/paddle/fluid/tests/unittests/test_lookup_table_v2_op.py @@ -16,11 +16,11 @@ import numpy as np from eager_op_test import OpTest, skip_check_grad_ci +from op import Operator import paddle from paddle import fluid from paddle.fluid import Program, core, program_guard -from paddle.fluid.op import Operator class TestStaticGraphSupportMultipleInt(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_merge_selectedrows_op.py b/python/paddle/fluid/tests/unittests/test_merge_selectedrows_op.py index 742fe4becd4f2..7c7f3a86da88c 100644 --- a/python/paddle/fluid/tests/unittests/test_merge_selectedrows_op.py +++ b/python/paddle/fluid/tests/unittests/test_merge_selectedrows_op.py @@ -15,9 +15,9 @@ import unittest import numpy as np +from op import Operator from paddle.fluid import core -from paddle.fluid.op import Operator class TestMergeSelectedRows(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_momentum_op.py b/python/paddle/fluid/tests/unittests/test_momentum_op.py index 3e6aadc77a73a..14081d1cd7319 100644 --- a/python/paddle/fluid/tests/unittests/test_momentum_op.py +++ b/python/paddle/fluid/tests/unittests/test_momentum_op.py @@ -17,11 +17,11 @@ import numpy import numpy as np from eager_op_test import OpTest +from op import Operator import paddle from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator def calculate_momentum_by_numpy( diff --git a/python/paddle/fluid/tests/unittests/test_operator.py b/python/paddle/fluid/tests/unittests/test_operator.py index c0d29671611da..da08e898ed82e 100644 --- a/python/paddle/fluid/tests/unittests/test_operator.py +++ b/python/paddle/fluid/tests/unittests/test_operator.py @@ -15,8 +15,8 @@ import unittest import numpy as np +import op -from paddle.fluid import op from paddle.fluid.proto import framework_pb2 diff --git a/python/paddle/fluid/tests/unittests/test_rmsprop_op.py b/python/paddle/fluid/tests/unittests/test_rmsprop_op.py index 6c09910c86de0..127abef28830b 100644 --- a/python/paddle/fluid/tests/unittests/test_rmsprop_op.py +++ b/python/paddle/fluid/tests/unittests/test_rmsprop_op.py @@ -15,11 +15,11 @@ import unittest import numpy as np +from op import Operator import paddle from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator def create_selected_rows_and_tensor( diff --git a/python/paddle/fluid/tests/unittests/test_scalar.py b/python/paddle/fluid/tests/unittests/test_scalar.py index 9bd22127921d7..3a49611c15c34 100644 --- a/python/paddle/fluid/tests/unittests/test_scalar.py +++ b/python/paddle/fluid/tests/unittests/test_scalar.py @@ -15,8 +15,9 @@ import unittest import numpy as np +import op -from paddle.fluid import framework, op +from paddle.fluid import framework class TestWarpAsScalar(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_scale_op.py b/python/paddle/fluid/tests/unittests/test_scale_op.py index 8dac4f6e0e7c6..c28ba1d1725d5 100644 --- a/python/paddle/fluid/tests/unittests/test_scale_op.py +++ b/python/paddle/fluid/tests/unittests/test_scale_op.py @@ -18,11 +18,11 @@ import numpy as np from decorator_helper import prog_scope from eager_op_test import OpTest, convert_float_to_uint16 +from op import Operator import paddle from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator from paddle.static import Program, program_guard diff --git a/python/paddle/fluid/tests/unittests/test_sgd_op.py b/python/paddle/fluid/tests/unittests/test_sgd_op.py index 17543e847d816..6fa74c14a874c 100644 --- a/python/paddle/fluid/tests/unittests/test_sgd_op.py +++ b/python/paddle/fluid/tests/unittests/test_sgd_op.py @@ -16,11 +16,11 @@ import numpy as np from eager_op_test import OpTest +from op import Operator import paddle from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator paddle.enable_static() diff --git a/python/paddle/fluid/tests/unittests/test_sgd_op_bf16.py b/python/paddle/fluid/tests/unittests/test_sgd_op_bf16.py index 761400ab8f99a..b528ffc05761f 100644 --- a/python/paddle/fluid/tests/unittests/test_sgd_op_bf16.py +++ b/python/paddle/fluid/tests/unittests/test_sgd_op_bf16.py @@ -16,11 +16,11 @@ import unittest import numpy as np +from op import Operator import paddle from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator from paddle.fluid.tests.unittests.eager_op_test import ( OpTest, OpTestTool, diff --git a/python/paddle/fluid/tests/unittests/test_shape_op.py b/python/paddle/fluid/tests/unittests/test_shape_op.py index 1fb37e06c6056..3609370e73cf8 100644 --- a/python/paddle/fluid/tests/unittests/test_shape_op.py +++ b/python/paddle/fluid/tests/unittests/test_shape_op.py @@ -16,10 +16,10 @@ import numpy as np from eager_op_test import OpTest, convert_float_to_uint16 +from op import Operator import paddle from paddle.fluid import core -from paddle.fluid.op import Operator class TestShapeOp(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_share_data_op.py b/python/paddle/fluid/tests/unittests/test_share_data_op.py index 6eae0abccfa68..b369652e0ee4d 100644 --- a/python/paddle/fluid/tests/unittests/test_share_data_op.py +++ b/python/paddle/fluid/tests/unittests/test_share_data_op.py @@ -16,9 +16,9 @@ import numpy as np from eager_op_test import OpTest +from op import Operator from paddle.fluid import core -from paddle.fluid.op import Operator class TestShareDataOp(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_sum_op.py b/python/paddle/fluid/tests/unittests/test_sum_op.py index 91e13d3686741..0f006eab26ff4 100644 --- a/python/paddle/fluid/tests/unittests/test_sum_op.py +++ b/python/paddle/fluid/tests/unittests/test_sum_op.py @@ -25,13 +25,13 @@ convert_float_to_uint16, convert_uint16_to_float, ) +from op import Operator import paddle import paddle.inference as paddle_infer from paddle import enable_static, fluid from paddle.fluid import core from paddle.fluid.layer_helper import LayerHelper -from paddle.fluid.op import Operator def sum_wrapper(X, use_mkldnn=False): diff --git a/python/paddle/fluid/tests/unittests/test_uniform_random_bf16_op.py b/python/paddle/fluid/tests/unittests/test_uniform_random_bf16_op.py index e76bbc80033fa..9d90ccacc43ea 100644 --- a/python/paddle/fluid/tests/unittests/test_uniform_random_bf16_op.py +++ b/python/paddle/fluid/tests/unittests/test_uniform_random_bf16_op.py @@ -16,11 +16,11 @@ import numpy as np from eager_op_test import OpTest, convert_uint16_to_float +from op import Operator import paddle from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator from paddle.fluid.tests.unittests.test_uniform_random_op import ( output_hist, output_hist_diag, diff --git a/python/paddle/fluid/tests/unittests/test_uniform_random_op.py b/python/paddle/fluid/tests/unittests/test_uniform_random_op.py index de1984098b938..ad74c34908bef 100644 --- a/python/paddle/fluid/tests/unittests/test_uniform_random_op.py +++ b/python/paddle/fluid/tests/unittests/test_uniform_random_op.py @@ -17,13 +17,13 @@ import numpy as np from eager_op_test import OpTest, convert_uint16_to_float +from op import Operator from test_attribute_var import UnittestBase import paddle from paddle import fluid from paddle.fluid import Program, core, program_guard from paddle.fluid.framework import convert_np_dtype_to_dtype_ -from paddle.fluid.op import Operator from paddle.tensor import random diff --git a/python/paddle/fluid/tests/unittests/testsuite.py b/python/paddle/fluid/tests/unittests/testsuite.py index 5ae73e386bf93..d4ab629ea2beb 100644 --- a/python/paddle/fluid/tests/unittests/testsuite.py +++ b/python/paddle/fluid/tests/unittests/testsuite.py @@ -13,9 +13,9 @@ # limitations under the License. import numpy as np +from op import Operator from paddle.fluid import core -from paddle.fluid.op import Operator def create_op(scope, op_type, inputs, outputs, attrs, cache_list=None): diff --git a/python/paddle/fluid/tests/unittests/xpu/test_adam_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_adam_op_xpu.py index faf49b5e22ada..6d44d355e4cdc 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_adam_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_adam_op_xpu.py @@ -27,7 +27,7 @@ import paddle from paddle.fluid import core -from paddle.fluid.op import Operator +from paddle.fluid.tests.unittests.op import Operator class XPUTestAdamOp(XPUOpTestWrapper): diff --git a/python/paddle/fluid/tests/unittests/xpu/test_fill_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_fill_op_xpu.py index 9abf799c2f9e4..4cb43a2ba430c 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_fill_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_fill_op_xpu.py @@ -27,7 +27,7 @@ import paddle from paddle.fluid import core -from paddle.fluid.op import Operator +from paddle.fluid.tests.unittests.op import Operator paddle.enable_static() diff --git a/python/paddle/fluid/tests/unittests/xpu/test_rmsprop_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_rmsprop_op_xpu.py index b0ddd3f9fea5a..c905eb9a57974 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_rmsprop_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_rmsprop_op_xpu.py @@ -29,7 +29,7 @@ import paddle from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator +from paddle.fluid.tests.unittests.op import Operator paddle.enable_static() diff --git a/python/paddle/fluid/tests/unittests/xpu/test_sgd_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_sgd_op_xpu.py index 738f0aff83e29..42cdfd0c82d2a 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_sgd_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_sgd_op_xpu.py @@ -28,7 +28,7 @@ import paddle from paddle import fluid from paddle.fluid import core -from paddle.fluid.op import Operator +from paddle.fluid.tests.unittests.op import Operator class XPUTestSgdOp(XPUOpTestWrapper): diff --git a/python/paddle/fluid/tests/unittests/xpu/test_shape_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_shape_op_xpu.py index 1c25661c138ad..2f8d7ec830077 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_shape_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_shape_op_xpu.py @@ -27,7 +27,7 @@ import paddle from paddle.fluid import core -from paddle.fluid.op import Operator +from paddle.fluid.tests.unittests.op import Operator paddle.enable_static() diff --git a/test/mkldnn/test_sum_mkldnn_op.py b/test/mkldnn/test_sum_mkldnn_op.py index 7c2c4708ef457..9871cfa48370e 100644 --- a/test/mkldnn/test_sum_mkldnn_op.py +++ b/test/mkldnn/test_sum_mkldnn_op.py @@ -16,8 +16,8 @@ import numpy as np -import paddle.fluid.op as fluid_op from paddle.fluid import core +from paddle.fluid.tests.unittests.op import Operator from paddle.fluid.tests.unittests.test_sum_op import TestSumOp @@ -70,7 +70,7 @@ def test_check_output(self): tensor = var.get_tensor() tensor.set(var_value, place) - sum_op = fluid_op.Operator( + sum_op = Operator( "sum", X=["x0", "x1"], Out=out_var_name, use_mkldnn=True ) expected_out = np.array(self.x0 + self.x1)