Tensor<T>.filled constructor
Constructs a Tensor filled with value
.
By default a 0-dimensional tensor with the single value is returned. If a
shape
is provided all tensor entries are filled with that value.
Implementation
factory Tensor.filled(T value,
{List<int>? shape, List<int>? strides, DataType<T>? type}) {
final type_ = type ?? DataType.fromInstance(value);
final layout_ = Layout(shape: shape, strides: strides);
final data_ = type_.newList(layout_.length, fillValue: value);
return Tensor.internal(type: type_, layout: layout_, data: data_);
}