asc2.zeros

asc2.zeros(shape: ~typing.Iterable[int], dtype: ~asc.language.core.dtype.DataType = <asc.language.core.dtype.DataType object>, location: ~asc._C.libpyasc.ir.TensorLocation = <TensorLocation.UB: 26>) LocalTensor

Create a tensor filled with zeros.

The supported data types are: int8, int16, int32, int64, float16, bfloat16, float32.

Parameters:
  • shape – The shape of the tensor to create.

  • dtype – The data type of the tensor. Default is int32.

  • location – The memory location for the tensor. Default is TensorLocation.UB.

Returns:

A new tensor filled with zeros

Return type:

LocalTensor

Raises:
  • TypeError – If dtype is not a DataType or location is not a TensorLocation

  • RuntimeError – If shape is invalid or dtype is not supported

Examples

Create a zero-filled tensor with default dtype (int32):

result = asc2.zeros([128])

Create a zero-filled tensor with a specific dtype:

result = asc2.zeros([32, 16], dtype=asc2.float16)