set_as

Description

Sets a Tensor.

Prototype

set_as(value, dst_offset=0, src_offset=None)

Parameters

Table 1 Parameter description

Parameter

Input/Output

Description

value

Input

Value to set. Supported data types:

  • A Scalar.
  • An Expr.
  • A Tensor. Can have only one element. Otherwise, the first element of the Tensor is used. Must be in the following scope:

    Atlas 200/300/500 Inference Product: scope_ubuf

    Atlas Training Series Product: scope_ubuf

dst_offset

Input

Reserved and not recommended.

src_offset

Input

Reserved and not recommended.

Applicability

Atlas 200/300/500 Inference Product

Atlas Training Series Product

Restrictions

  1. To set a Tensor to a Scalar value, they must be of the same data type.
  2. The destination Tensor must be in the scope_ubuf scope.
  3. Only the first element of the destination Tensor is changed.
  4. Setting a Tensor of type int/uint to an Expr value is supported only when the Expr's Scalar is of type int or uint and the Expr's immediate is of type int or float.
  5. For the Atlas 200/300/500 Inference Product, setting a Scalar of type float16 or float32 to an Expr value is not supported.

    For the Atlas Training Series Product, setting a Scalar of type float16 to an Expr value is not supported.

Returns

None

Example

from tbe import tik
tik_instance = tik.Tik()
data_A = tik_instance.Tensor("float16", (128,), name="data_A", scope=tik.scope_ubuf)
data_B = tik_instance.Tensor("float16", (128,), name="data_A", scope=tik.scope_ubuf)
data_A[0].set_as(data_B[0:1])