asc2.full

asc2.full(shape: ~typing.Iterable[int], value: ~asc.language.core.ir_value.PlainValue | int | float, dtype: ~asc.language.core.dtype.DataType | None = None, location: ~asc._C.libpyasc.ir.TensorLocation = <TensorLocation.UB: 26>) LocalTensor

Create a tensor filled with a scalar value.

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

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

  • value – The scalar value to fill the tensor with.

  • dtype – The data type of the tensor. If None, inferred from the value type.

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

Returns:

A new tensor filled with the specified value

Return type:

LocalTensor

Raises:
  • TypeError – If value is not a numeric type, dtype is not a DataType, or location is not a TensorLocation

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

Examples

Create a tensor filled with a constant integer value:

result = asc2.full([128], 42, dtype=asc2.int32)

Create a tensor filled with a floating-point value:

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

Create a tensor with dtype inferred from the value:

result = asc2.full([64], 0)       # inferred as int32
result = asc2.full([64], 1.5)     # inferred as float32