Changing the Tensor Content
Description
Sets the content of a Tensor by index.
Prototype
__setitem__(index, value)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
index |
Input |
Tensor index. Must be one of the following data types:
|
value |
Input |
Value to set. Supported data types: |
Applicability
Restrictions
1. The destination Tensor must be in the scope_ubuf scope.
2. Only the first element of the destination Tensor is changed.
3. The alignment requirements for slice vary with the scope. start must meet the following requirements:
- Unified Buffer: 32-byte aligned
- Global Memory: no alignment requirement
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)
scalar_B = tik_instance.Scalar(dtype="float16", name="scalar_B", init_value=2.0)
data_A[0] = scalar_B
Parent topic: Tensor Management