torch.masked_select_async
Async version of masked_select that returns a tensor with exact shape. Returns a 1D tensor containing exactly the elements where mask is True.
Parameters
Returns
Promise<Tensor>– Promise resolving to a 1D tensor with selected elements (exact shape)Examples
const x = torch.tensor([1, 2, 3, 4]);
const mask = torch.tensor([true, false, true, false]);
const result = await torch.masked_select_async(x, mask);
result.shape; // [2] - exactly 2 elements selected