Adds a layer that finds the indices of non-zero values of the input tensor. Parameters: input: Tensor The input tensor for which we need to find the indices of non-zero values. Returns: A tensor of shape [D, C] where D is the number of dimensions of `input`
(input: Tensor)
| 2334 | |
| 2335 | |
| 2336 | def nonzero(input: Tensor) -> Tensor: |
| 2337 | ''' |
| 2338 | Adds a layer that finds the indices of non-zero values of the input tensor. |
| 2339 | |
| 2340 | Parameters: |
| 2341 | input: Tensor |
| 2342 | The input tensor for which we need to find the indices of non-zero values. |
| 2343 | Returns: |
| 2344 | A tensor of shape [D, C] where D is the number of dimensions of `input` and |
| 2345 | C is the number of non-zero values in it. |
| 2346 | Each column of this 2D tensor represents the index tuple for each non-zero value. |
| 2347 | ''' |
| 2348 | non_zero_layer = default_trtnet().add_non_zero(input.trt_tensor) |
| 2349 | return _create_tensor(non_zero_layer.get_output(0), non_zero_layer) |
| 2350 | |
| 2351 | |
| 2352 | def masked_select(input: Tensor, mask: Tensor) -> Tensor: |
no test coverage detected