asc2.global_tensor
- asc2.global_tensor(base: GlobalAddress, shape: Iterable[PlainValue | int]) GlobalTensor
Define a new tensor descriptor for accessing data in global memory.
Tensors represent contiguous ND-arrays in global memory and are used to transfer data between global and local memory via
copy_in()andcopy_out()operations.- Parameters:
base – The base address of an array in global memory representing the tensor
shape – An iterable of integer-like values representing the number of elements for each dimension
- Returns:
A new tensor descriptor
- Return type:
- Raises:
TypeError – If base is not a GlobalAddress or shape contains non-integer values
RuntimeError – If shape is empty
Examples
Create a 1D tensor with static shape:
x_gm = asc2.global_tensor(x_ptr, [1024])
Create a 2D tensor with static shape:
x_gm = asc2.global_tensor(x_ptr, [64, 128])
Create a tensor with dynamic shape (using runtime values):
x_gm = asc2.global_tensor(x_ptr, [num_rows, num_cols])