zeros static method
Implementation
static Tensor zeros(List<int> shape) {
final int rows = shape[0];
final int cols = shape.length > 1 ? shape[1] : 1;
final int size = rows * cols;
// Allocate native memory filled with 0.0
final ffi.Pointer<ffi.Float> buffer = calloc<ffi.Float>(size);
// calloc usually zeros memory, but let's be explicit
for (int i = 0; i < size; i++) {
buffer[i] = 0.0;
}
final handle = engine.createTensor(rows, cols, buffer);
calloc.free(buffer);
return Tensor._raw(handle, shape);
}