Table of Contents

Class TensorCopyHelper

Namespace
AiDotNet.Helpers
Assembly
AiDotNet.dll

Helper class for tensor copy operations.

public static class TensorCopyHelper
Inheritance
TensorCopyHelper
Inherited Members

Remarks

TensorCopyHelper provides utility methods for copying data between tensors, particularly for copying individual samples from one tensor to another.

For Beginners: When working with batched data in tensors, you often need to copy individual samples between tensors. This helper provides optimized methods for this common operation.

Methods

CopySample<T>(Tensor<T>, Tensor<T>, int, int)

Copies a single sample from one tensor to another.

public static void CopySample<T>(Tensor<T> source, Tensor<T> dest, int sourceIndex, int destIndex)

Parameters

source Tensor<T>

The source tensor to copy from.

dest Tensor<T>

The destination tensor to copy to.

sourceIndex int

The index of the sample in the source tensor (first dimension).

destIndex int

The index where to place the sample in the destination tensor (first dimension).

Type Parameters

T

The numeric type of the tensor elements.

Remarks

This method copies all elements for a single sample from the source tensor to the destination tensor. For a tensor of shape [N, H, W, C], this copies all H*W*C elements for sample at sourceIndex to destIndex.

For Beginners: Think of a tensor as a multi-dimensional array where the first dimension represents individual samples. This method copies one complete sample (all its data across other dimensions) from one position to another.