Tensor<T>.generate constructor

Tensor<T>.generate(
  1. T callback(
    1. List<int> key
    ), {
  2. required List<int> shape,
  3. List<int>? strides,
  4. DataType<T>? type,
})

Constructs a Tensor filled with the results of callback.

Implementation

factory Tensor.generate(T Function(List<int> key) callback,
        {required List<int> shape, List<int>? strides, DataType<T>? type}) =>
    Tensor.fromIterable(Layout(shape: shape).keys.map(callback),
        shape: shape, strides: strides, type: type ?? DataType.fromType<T>());