未验证 提交 2f75465d 编写于 作者: L lilong12 提交者: GitHub

fix the call to core.ops.x, test=develop (#26729)

上级 f1ae017f
...@@ -23,7 +23,6 @@ from ..fluid.layers import utils ...@@ -23,7 +23,6 @@ from ..fluid.layers import utils
import numpy as np import numpy as np
# TODO: define functions to manipulate a tensor # TODO: define functions to manipulate a tensor
from ..fluid.layers import cast #DEFINE_ALIAS from ..fluid.layers import cast #DEFINE_ALIAS
from ..fluid.layers import expand_as #DEFINE_ALIAS
from ..fluid.layers import slice #DEFINE_ALIAS from ..fluid.layers import slice #DEFINE_ALIAS
from ..fluid.layers import strided_slice #DEFINE_ALIAS from ..fluid.layers import strided_slice #DEFINE_ALIAS
from ..fluid.layers import transpose #DEFINE_ALIAS from ..fluid.layers import transpose #DEFINE_ALIAS
...@@ -1100,6 +1099,9 @@ def tile(x, repeat_times, name=None): ...@@ -1100,6 +1099,9 @@ def tile(x, repeat_times, name=None):
np_out = out.numpy() np_out = out.numpy()
# [[1, 2, 3], [1, 2, 3]] # [[1, 2, 3], [1, 2, 3]]
""" """
if in_dygraph_mode():
return core.ops.tile(x, 'repeat_times', repeat_times)
check_variable_and_dtype( check_variable_and_dtype(
x, 'x', ['bool', 'float32', 'float64', 'int32', 'int64'], 'tile') x, 'x', ['bool', 'float32', 'float64', 'int32', 'int64'], 'tile')
check_type(repeat_times, 'repeat_times', (list, tuple, Variable), 'tile') check_type(repeat_times, 'repeat_times', (list, tuple, Variable), 'tile')
...@@ -1109,9 +1111,6 @@ def tile(x, repeat_times, name=None): ...@@ -1109,9 +1111,6 @@ def tile(x, repeat_times, name=None):
"must set its stop_gradient to be True by " "must set its stop_gradient to be True by "
"some_var.stop_gradient == True supporting some_var is the input.") "some_var.stop_gradient == True supporting some_var is the input.")
if in_dygraph_mode():
return core.ops.tile(x, 'repeat_times', repeat_times)
helper = LayerHelper('tile', **locals()) helper = LayerHelper('tile', **locals())
inputs = {"X": [x]} inputs = {"X": [x]}
...@@ -1176,6 +1175,9 @@ def expand_as(x, y, name=None): ...@@ -1176,6 +1175,9 @@ def expand_as(x, y, name=None):
np_out = out.numpy() np_out = out.numpy()
# [[1, 2, 3], [1, 2, 3]] # [[1, 2, 3], [1, 2, 3]]
""" """
if in_dygraph_mode():
return core.ops.expand_as_v2(x, y)
check_variable_and_dtype( check_variable_and_dtype(
x, 'x', ['bool', 'float32', 'float64', 'int32', 'int64'], 'expand_as') x, 'x', ['bool', 'float32', 'float64', 'int32', 'int64'], 'expand_as')
check_type(y, 'y', Variable, 'expand_as') check_type(y, 'y', Variable, 'expand_as')
...@@ -1188,9 +1190,6 @@ def expand_as(x, y, name=None): ...@@ -1188,9 +1190,6 @@ def expand_as(x, y, name=None):
"some_var as the input 'x'.") "some_var as the input 'x'.")
inputs = {"X": [x], "target_tensor": [y]} inputs = {"X": [x], "target_tensor": [y]}
if in_dygraph_mode():
return core.ops.expand_as_v2(x, y)
helper = LayerHelper('expand_as', **locals()) helper = LayerHelper('expand_as', **locals())
dtype = helper.input_dtype(input_param_name='x') dtype = helper.input_dtype(input_param_name='x')
out = helper.create_variable_for_type_inference(dtype) out = helper.create_variable_for_type_inference(dtype)
...@@ -1229,6 +1228,9 @@ def expand(x, shape, name=None): ...@@ -1229,6 +1228,9 @@ def expand(x, shape, name=None):
out = out.numpy() out = out.numpy()
# [[1, 2, 3], [1, 2, 3]] # [[1, 2, 3], [1, 2, 3]]
""" """
if in_dygraph_mode():
return core.ops.expand_v2(x, 'shape', shape)
check_variable_and_dtype( check_variable_and_dtype(
x, 'x', ['bool', 'float32', 'float64', 'int32', 'int64'], 'expand') x, 'x', ['bool', 'float32', 'float64', 'int32', 'int64'], 'expand')
check_type(shape, 'shape', (list, tuple, Variable), 'expand') check_type(shape, 'shape', (list, tuple, Variable), 'expand')
...@@ -1241,9 +1243,6 @@ def expand(x, shape, name=None): ...@@ -1241,9 +1243,6 @@ def expand(x, shape, name=None):
"some_var.stop_gradient = True, supporting " "some_var.stop_gradient = True, supporting "
"some_var as the input.") "some_var as the input.")
if in_dygraph_mode():
return core.ops.expand_v2(x, 'shape', shape)
helper = LayerHelper('expand', **locals()) helper = LayerHelper('expand', **locals())
def get_attr_expand_shape(list_expand_shape): def get_attr_expand_shape(list_expand_shape):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册