Add an operation to compute the sum along a dimension. Computes the sum along the dimension 'dim' of the input tensor. It is implemented using the IReduceLayer from TensorRT. Parameters: input : Tensor The input tensor. dim : int The dimen
(input: Tensor, dim: int, keepdim: bool = False)
| 3251 | |
| 3252 | |
| 3253 | def sum(input: Tensor, dim: int, keepdim: bool = False) -> Tensor: |
| 3254 | ''' |
| 3255 | Add an operation to compute the sum along a dimension. |
| 3256 | |
| 3257 | Computes the sum along the dimension 'dim' of the input tensor. |
| 3258 | |
| 3259 | It is implemented using the IReduceLayer from TensorRT. |
| 3260 | |
| 3261 | Parameters: |
| 3262 | input : Tensor |
| 3263 | The input tensor. |
| 3264 | |
| 3265 | dim : int |
| 3266 | The dimension along which the mean is computed. |
| 3267 | |
| 3268 | keepdim : bool |
| 3269 | Is the dimension kept in the reduced tensor? When True the |
| 3270 | dimension is kept, it is removed from the shape otherwise. |
| 3271 | |
| 3272 | Returns: |
| 3273 | The tensor produced by this reduction operation. |
| 3274 | ''' |
| 3275 | return reduce(input, op=trt.ReduceOperation.SUM, dim=dim, keepdim=keepdim) |
| 3276 | |
| 3277 | |
| 3278 | def identity(input: Tensor) -> Tensor: |