espnet2.asr.encoder.avhubert_encoder.is_xla_tensor
Less than 1 minute
espnet2.asr.encoder.avhubert_encoder.is_xla_tensor
espnet2.asr.encoder.avhubert_encoder.is_xla_tensor(tensor)
Check if a given tensor is an XLA tensor.
This function determines if the input tensor is a PyTorch tensor that is located on an XLA device. XLA (Accelerated Linear Algebra) is a domain-specific compiler for linear algebra that can accelerate TensorFlow and PyTorch computations on TPUs.
- Parameters:tensor (torch.Tensor) – The tensor to check.
- Returns: True if the tensor is an XLA tensor, False otherwise.
- Return type: bool
Examples
>>> import torch
>>> xla_tensor = torch.tensor([1, 2, 3], device='xla')
>>> cpu_tensor = torch.tensor([1, 2, 3])
>>> is_xla_tensor(xla_tensor)
True
>>> is_xla_tensor(cpu_tensor)
False
NOTE
Ensure that you have the necessary environment set up for XLA tensors when using this function.