clone method

TensorBuffer clone()

Creates a deep copy of this tensor with its own storage.

Implementation

TensorBuffer clone() {
  final newData = dtype.createBuffer(numel);
  _copyToContiguous(newData);

  return TensorBuffer(
    storage: TensorStorage(newData, dtype),
    shape: shape.toList(),
    memoryFormat: MemoryFormat.contiguous,
  );
}