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

Function append

python/paddle/base/layers/math_op_patch.py:397–420  ·  view source on GitHub ↗

Note: The type variable must be LoD Tensor Array.

(self, var)

Source from the content-addressed store, hash-verified

395
396 @static_only
397 def append(self, var):
398 """
399
400 Note:
401 The type variable must be LoD Tensor Array.
402
403 """
404 if not isinstance(var, Variable):
405 if in_to_static_mode():
406 """In dy2static mode, x may be tensor values such as int, float, np.array"""
407 from paddle.tensor.creation import to_tensor
408
409 var = to_tensor(var)
410 else:
411 raise TypeError(
412 f"Required input var should be Variable, but received {type(var)}"
413 )
414 if self.type != core.VarDesc.VarType.DENSE_TENSOR_ARRAY:
415 raise TypeError(
416 f"Only Variable with VarType.DENSE_TENSOR_ARRAY support `append` method, but received type: {self.type}"
417 )
418 from paddle.tensor.array import array_length, array_write
419
420 array_write(x=var, i=array_length(self), array=self)
421
422 @static_only
423 def _item(self):

Callers

nothing calls this directly

Calls 6

to_tensorFunction · 0.90
array_writeFunction · 0.90
array_lengthFunction · 0.90
in_to_static_modeFunction · 0.85
TypeErrorClass · 0.85
typeFunction · 0.50

Tested by

no test coverage detected