copy#
Copy an operator into a tensor. This is equivalent to (a = b), but may be optimized further since it cannot be chained with other expressions.
With a CUDA executor, copies between contiguous, dense tensor views of the same
element type use cudaMemcpyAsync on the executor’s stream. This also applies
to the CUDA stream overloads and the overloads that return a new tensor. No
additional build options or dependencies are required. Synchronize the executor
or stream before accessing the copied data from the host.
Sparse sources, noncontiguous views, copies that convert element types, and expression inputs
use executor-dispatched assignment. Host executors continue to use assignment.
Source and destination must have matching ranks and sizes, and their memory
regions must not overlap.
With MATX_EN_UNSAFE_ALIAS_DETECTION enabled, the CUDA byte-copy path uses
the same alias check as assignment and throws on detected unsafe overlap before
issuing the copy.
Added in version 0.3.0.
-
template<typename OutputTensor, typename InputTensor, typename Executor>
__MATX_INLINE__ void matx::copy(OutputTensor &out, const InputTensor &in, Executor exec)# Make a deep copy of a view into another view
Copies the data from a view into another view. Views should normally be backed by different data objects, but it’s not necessary if there is no overlap between the soure and destination. If the source in destination overlap in any way, it is a race condition and the result of the operation is undefined.
Both tensor views must be the same rank and size in every dimension
- Parameters:
out – Tensor to copy into
in – Tensor to copy from
exec – Executor to run copy in
-
template<typename OutputTensor, typename InputTensor>
__MATX_INLINE__ void matx::copy(OutputTensor &out, const InputTensor &in, cudaStream_t stream = 0)#
-
template<typename Tensor, typename Executor>
__MATX_INLINE__ Tensor matx::copy(const Tensor &in, Executor exec)# Make a deep copy of a view into a new tensor.
Creates a new tensor of the same rank and dimension as the input view. Copies the data from the input view into the new tensor and returns it.
- Parameters:
in – Tensor to copy from
exec – Executor to run copy in
- Returns:
New tensor into which the input view has been copied
-
template<typename Tensor>
__MATX_INLINE__ Tensor matx::copy(const Tensor &in, cudaStream_t stream = 0)#
Examples#
matx::copy(i_pad_part_v, i, stream);