copy method

Tensor<T> copy({
  1. bool contiguous = false,
})

Copies the data of this tensor.

Only if contiguous is set to true, the data is realigned so that the layout is contiguous.

Implementation

Tensor<T> copy({bool contiguous = false}) {
  final (layout_, data_) = contiguous
      ? (Layout(shape: layout.shape), type.copyList(values))
      : (layout, type.copyList(data));
  return Tensor.internal(type: type, layout: layout_, data: data_);
}