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 training product: scope_ubuf

    Atlas inference product AI Core: scope_ubuf or scope_gm

    Atlas inference product Vector Core: scope_ubuf or scope_gm

    SoC (TsnsC): scope_ubuf or scope_gm

    Atlas 200I/500 A2 inference product: scope_ubuf or scope_gm

dst_offset

Input

Reserved and not recommended.

src_offset

Input

Reserved and not recommended.

Applicability

Atlas training product

Atlas inference product AI Core

Atlas inference product Vector Core

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference 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 training product, setting a Scalar of type float16 to an Expr value is not supported.

    For the Atlas inference product AI Core, setting a Scalar of type float16 to an Expr value is not supported.

    For the Atlas inference product Vector Core, setting a Scalar of type float16 to an Expr value is not supported.

    For the Atlas A2 training product/Atlas A2 inference product, setting a Scalar of type float16 to an Expr value is not supported.

    For the Atlas 200I/500 A2 inference 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])