Tensor Utils

Tensor Utils#

The xlnstorch.tensor_utils module provides utility functions for working with LNSTensor objects and helpers for useful quantities.

toggle_cpp_tensor_utils(use_cpp)

Toggle the use of C++ implementations for tensor utility functions.

get_base_from_precision(f)

Get the logarithmic base for a given precision.

get_precision_from_base(base[, tolerance])

Get the precision for a given logarithmic base, if it matches a precomputed base.

set_overflow_limits([max, min])

Set global overflow limits for the handle_overflow function.

handle_overflow(*tensors[, inplace, no_grad])

Handle overflow for a variable number of LNSTensors based on global overflow limits.

align_lnstensor_bases(*tensors[, base])

Aligns the bases of a sequence of LNSTensors to a common base.

format_lnstensor_operands(*operands[, base])

Converts a variable number of operands to LNSTensor objects, aligning all operands to the base of the first operand that is an LNSTensor.