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
Parameter |
Input Type |
Description |
|---|---|---|
mem_type |
String |
Location of the memory space where the abstracted tensor is located, such as GM, UB, L1, L0A, L0B, L0C, FB, and BT. |
dtype |
String |
Data type, such as BOOL, UINT1, UINT2, UINT8, UINT16, UINT32, BF16, UINT64, INT4, INT8, INT16, INT32, INT64, FP16, and FP32. |
size |
list |
Shape of a tensor. |
format |
String |
|
is_inited |
bool |
Switch that indicates whether the tensor class is ready. Once enabled, instructions that utilize the tensors as the input can be initiated. |
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_temp.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: Description of msKPP External APIs