Tensor
Function
Onboard tensor abstraction, in which the memory location, data type, size, and format of tensors can be specified as the data dependency identifiers of instructions.
Prototype
1 | class Tensor(mem_type, dtype=None, size=None, format=None, is_inited=False) |
Parameters
Members
Member |
Description |
|---|---|
tensor.set_valid() |
Enables the current tensor to be ready. Once enabled, instructions that utilize the tensor as the input can be initiated immediately. |
tensor.set_invalid() |
Disables the current tensor to be ready. Once disabled, instructions that utilize the tensor as the input cannot be initiated immediately. |
tensor.is_valid() |
Obtains the current tensor ready status. |
Constraints
You need to create a tensor whose shape is [1] and is_inited is True for scalar creation.
Example
1 2 3 4 5 6 7 8 9 | from mskpp import Tensor, Core gm_tmp= Tensor("GM", "FP16", [48, 16], format="ND") with Core("AIV0") as aiv: # Computing logic on AIV0. ... gm_tmp.load(result, set_value=0) with Core("AIC0") as aic: in_x = Tensor("GM", "FP16", [48, 16], format="ND") in_x.load(gm_tmp, expect_value=0) # Computing logic on AIC0. ... |
Parent topic: Basic APIs