Tensor.fill constructor
Implementation
factory Tensor.fill(List<int> shape, double val) {
final ptr = calloc<ffi.Float>(shape.reduce((a, b) => a * b));
for (int i = 0; i < shape.reduce((a, b) => a * b); i++) {
ptr[i] = val;
}
final h = engine.createTensor(
shape[0],
shape.length > 1 ? shape[1] : 1,
ptr,
);
calloc.free(ptr);
return Tensor._raw(h, shape);
}