bitorch_engine.functions.cuda.functions.tensor_to_packed_uint8

bitorch_engine.functions.cuda.functions.tensor_to_packed_uint8(input: Tensor) Tensor[source]

Packs the given tensor into an 8-bit unsigned integer tensor representation on CUDA.

This function converts a tensor of various data types (int8, float32, bfloat16, half) to an 8-bit unsigned integer tensor using CUDA kernels for efficient computation. It ensures that the operation is performed on the correct CUDA device by employing a device guard based on the input tensor’s device. If the data type of the input tensor is not supported, the function will terminate the program with an error message.

Parameters:

input (torch.Tensor) – The input tensor to be packed. Can be of type int8, float32, bfloat16, or half.

Returns:

An 8-bit unsigned integer representation of the input tensor.

Return type:

torch.Tensor

Note

The input tensor must be on a CUDA device. The function terminates the program if the input tensor’s type is not supported.