MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / _get_shape_tensor

Function _get_shape_tensor

python/paddle/utils/layers_utils.py:418–436  ·  view source on GitHub ↗
(list_shape)

Source from the content-addressed store, hash-verified

416 return attr_shape
417
418 def _get_shape_tensor(list_shape):
419 shape_tensor_list = []
420 for idx, dim in enumerate(list_shape):
421 if isinstance(dim, Variable):
422 dim.stop_gradient = True
423 check_dtype(
424 dim.dtype,
425 'shape[' + str(idx) + ']',
426 ['int32', 'int64'],
427 op_type,
428 f'(When type of shape in {op_type} is list or tuple.)',
429 )
430 if convert_dtype(dim.dtype) == 'int64':
431 dim = paddle.cast(x=dim, dtype='int32')
432 shape_tensor_list.append(dim)
433 else:
434 temp_out = fill_constant([], 'int32', dim, force_cpu=True)
435 shape_tensor_list.append(temp_out)
436 return shape_tensor_list
437
438 if isinstance(shape, Variable):
439 shape.stop_gradient = True

Callers 1

get_shape_tensor_inputsFunction · 0.85

Calls 6

fill_constantFunction · 0.90
strFunction · 0.85
check_dtypeFunction · 0.50
convert_dtypeFunction · 0.50
castMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected