Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions python/paddle/nn/functional/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def affine_grid(
theta, 'theta', ['float32', 'float64'], 'affine_grid'
)
out = helper.create_variable_for_type_inference(dtype=theta.dtype)
ipts = {'Theta': theta}
inputs = {'Theta': theta}
attrs = {"align_corners": align_corners, "use_cudnn": use_cudnn}
if isinstance(out_shape, Variable):
ipts['OutputShape'] = out_shape
inputs['OutputShape'] = out_shape
check_variable_and_dtype(
out_shape, 'out_shape', ['int32'], 'affine_grid'
)
Expand All @@ -130,7 +130,7 @@ def affine_grid(

helper.append_op(
type='affine_grid',
inputs=ipts,
inputs=inputs,
outputs={'Output': out},
attrs=None if len(attrs) == 0 else attrs,
)
Expand Down Expand Up @@ -317,7 +317,7 @@ def grid_sample(
check_variable_and_dtype(
grid, 'grid', ['float32', 'float64'], 'grid_sample'
)
ipts = {'X': x, 'Grid': grid}
inputs = {'X': x, 'Grid': grid}
attrs = {
'mode': mode,
'padding_mode': padding_mode,
Expand All @@ -327,7 +327,7 @@ def grid_sample(
out = helper.create_variable_for_type_inference(x.dtype)
helper.append_op(
type='grid_sampler',
inputs=ipts,
inputs=inputs,
attrs=attrs,
outputs={'Output': out},
)
Expand Down
12 changes: 6 additions & 6 deletions python/paddle/tensor/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,12 +961,12 @@ def _attr_offsets_check(offset_val):
return _C_ops.crop(x, shape, offsets)

out = helper.create_variable_for_type_inference(x.dtype)
ipts = {'X': x}
inputs = {'X': x}
attrs = {}

if isinstance(offsets, Variable):
offsets.stop_gradient = True
ipts['Offsets'] = offsets
inputs['Offsets'] = offsets
attrs['offsets'] = [-1] * len(x.shape)
elif paddle.utils._contain_var(offsets):
new_offsets_tensor = []
Expand All @@ -982,7 +982,7 @@ def _attr_offsets_check(offset_val):
fill_constant([1], 'int32', dim, force_cpu=True, out=temp_out)
new_offsets_tensor.append(temp_out)
offsets_attr.append(dim)
ipts['OffsetsTensor'] = new_offsets_tensor
inputs['OffsetsTensor'] = new_offsets_tensor
attrs['offsets'] = offsets_attr
else:
for offset in offsets:
Expand All @@ -991,7 +991,7 @@ def _attr_offsets_check(offset_val):

if isinstance(shape, Variable):
shape.stop_gradient = True
ipts['Shape'] = shape
inputs['Shape'] = shape
elif paddle.utils._contain_var(shape):
new_shape_tensor = []
shape_attr = []
Expand All @@ -1008,7 +1008,7 @@ def _attr_offsets_check(offset_val):
)
new_shape_tensor.append(temp_out)
shape_attr.append(dim_size)
ipts['ShapeTensor'] = new_shape_tensor
inputs['ShapeTensor'] = new_shape_tensor
attrs['shape'] = shape_attr
else:
for dim_size in shape:
Expand All @@ -1017,7 +1017,7 @@ def _attr_offsets_check(offset_val):

helper.append_op(
type='crop_tensor',
inputs=ipts,
inputs=inputs,
outputs={'Out': out},
attrs=None if len(attrs) == 0 else attrs,
)
Expand Down
Loading