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

Function _create_tensor

python/paddle/base/framework.py:1571–1592  ·  view source on GitHub ↗
(
    type=core.VarDesc.VarType.DENSE_TENSOR,
    name=None,
    shape=None,
    dtype=None,
    persistable=None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

1569
1570
1571def _create_tensor(
1572 type=core.VarDesc.VarType.DENSE_TENSOR,
1573 name=None,
1574 shape=None,
1575 dtype=None,
1576 persistable=None,
1577 **kwargs,
1578):
1579 if dtype is not None:
1580 dtype = convert_to_proto_type(dtype)
1581 else:
1582 dtype = core.VarDesc.VarType.FP32
1583
1584 eager_tensor = core.eager.Tensor(
1585 dtype,
1586 list(shape) if shape else [],
1587 name,
1588 type if type else core.VarDesc.VarType.DENSE_TENSOR,
1589 True if persistable else False,
1590 )
1591 eager_tensor.retain_grads()
1592 return eager_tensor
1593
1594
1595def _all_is_type(vals, expected_type):

Callers 13

_lod_tensor2varbaseFunction · 0.90
accuracyFunction · 0.90
dynamic_forwardMethod · 0.90
_linearFunction · 0.90
_inplace_reshape_dygraphFunction · 0.90
parameters_to_vectorFunction · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
accuracyFunction · 0.85

Calls 3

convert_to_proto_typeFunction · 0.85
listFunction · 0.85
TensorMethod · 0.45

Tested by

no test coverage detected