Skip to main content

ClikaRT::ops::to

function

3 overloads.

to(Tensor, StreamOrDevice)

Tensor to(Tensor src, StreamOrDevice target = {})

Moves a tensor to a device or stream.

Already-resident inputs pass through (no transfer). The result is produced on target's stream; downstream ops on that stream order after the transfer automatically.

Parameters

  • src: the source tensor.
  • target: destination stream or device. Default: src's stream.

Throws

  • ClikaRT::Error: when the input's dtype/shape is not served for this operation (the machine-readable reason rides code_name()).

Returns: the tensor on the destination device.

Declared in ClikaRT/compute/ops.h, line 2030

to(Span< Tensor>, StreamOrDevice)

std::vector<Tensor> to(ClikaRT::Span<const Tensor> tensors, StreamOrDevice target = {})

Multi-tensor to: moves a batch in ONE call; the batched transfer beats N single moves when several tensors cross together (one submission, one ordering point).

Parameters

  • tensors: the tensors to move.
  • target: destination stream or device.

Throws

  • ClikaRT::Error: when the input's dtype/shape is not served for this operation (the machine-readable reason rides code_name()).

Returns: the moved tensors, in input order.

Declared in ClikaRT/compute/ops.h, line 2040

to(Tensor, string_view)

Tensor to(Tensor src, std::string_view device_str)

String-addressed to: the device is named by string: "cpu", "cuda", "cuda:1", ….

Parameters

  • src: the source tensor.
  • device_str: the device name.

Throws

  • ClikaRT::Error: when the string names no available device, or the transfer cannot be served (code_name() carries the reason).

Returns: the tensor on the named device.

Declared in ClikaRT/compute/ops.h, line 2050