torchtraining.cast¶
Cast tensors in a functional fashion.
Users can use this module to cast step outputs to desired type or
to lower precision in order to save memory (though it shouldn’t be needed.)
-
class
torchtraining.cast.As(other)[source]¶ Cast
torch.Tensorto the same type asother.- Parameters
other (torch.Tensor) – Tensor according to which incoming tensor will be casted.
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.BFloat16(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to BFloat16.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Bool(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to Bool.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Byte(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to Byte.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Char(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to Char.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Double(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to Double.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Float(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to Float.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
torchtraining.cast.Float16¶ alias of
torchtraining.cast.Half
-
torchtraining.cast.Float32¶ alias of
torchtraining.cast.Float
-
torchtraining.cast.Float64¶ alias of
torchtraining.cast.Double
-
class
torchtraining.cast.Half(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to Half.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Int(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to Int.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
torchtraining.cast.Int16¶ alias of
torchtraining.cast.Short
-
torchtraining.cast.Int32¶ alias of
torchtraining.cast.Int
-
torchtraining.cast.Int64¶ alias of
torchtraining.cast.Long
-
torchtraining.cast.Int8¶ alias of
torchtraining.cast.Char
-
class
torchtraining.cast.Item[source]¶ Cast
torch.Tensorinstance to Item.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.List[source]¶ Cast
torch.Tensorinstance to List.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Long(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to Long.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.MKLDNN[source]¶ Cast
torch.Tensorinstance to MKLDNN.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Numpy[source]¶ Cast
torch.Tensorinstance to Numpy.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Short(memory_format=torch.preserve_format)[source]¶ Cast
torch.Tensorinstance to Short.Note
IMPORTANT: Only
torch.Tensorcan be passed asmemory_formatis specified during casting.- Returns
Casted
data- Return type
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
class
torchtraining.cast.Sparse(sparse_dims=None)[source]¶ Cast
torch.Tensorto sparse format.- Parameters
sparse_dims (int, optional) – The number of sparse dimensions to include in the new sparse tensor. Default:
None.
-
forward(data)[source]¶ - Parameters
data (torch.Tensor) – Tensor to be casted
-
torchtraining.cast.UInt8¶ alias of
torchtraining.cast.Byte