torch.Tensor.Tensor.isposinf
Checks for positive infinity.
Returns a boolean tensor where true indicates the corresponding element is +Infinity. Useful for directional overflow detection.
Use Cases:
- Detecting positive overflow separately from negative
- Identifying divergence in specific directions
- Asymmetric error handling
- Overflow diagnosis
- Floating point: Only meaningful for floating point dtypes
- Directional: Detects only positive infinity, not negative
- Return type: Always returns boolean tensor
Returns
Tensor<S, D, Dev>– Boolean tensor where true indicates +InfinityExamples
// Detect positive overflow
const x = torch.tensor([1.0, Infinity, -Infinity, 2.0]);
x.isposinf(); // [false, true, false, false]
// Separate positive and negative overflow
const values = torch.tensor([1.0, Infinity, -Infinity]);
const posOverflow = values.isposinf().sum();
const negOverflow = values.isneginf().sum();See Also
- PyTorch torch.isposinf()
- isneginf - Check for negative infinity
- isinf - Check for any infinity
- isfinite - Check for finite values