Special handling for 0-D tensor
Summary: `ET_CHECK_VALID_DIM` checks whether a tensor has a valid dimension. However, for 0-D tensors, some behaviors are different. Accessing size/stride for dim=0 is invalid, because the valid dimension is [-0, 0) which is none. ``` torch.tensor(2).size(dim=0) ``` However, some ops allow accessing dim=0 or -1 for a 0-D tensor ``` torch.mean(torch.tensor(2, dtype=float), dim=-1) ``` Therefore, in reduce_util helper functions and ops, we need to special handle that case. We also want to revisit this check for 0-D tensor case for ops. Reviewed By: manuelcandales Differential Revision: D48319644 fbshipit-source-id: 0a394ab4caccbcbb7868ccd371276e9dd047f054
H
Hansong Zhang committed
3c2adcb2a7fe36b3f8b2d91cac70a8b40e70e00d
Parent: 7108fb3
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 8/14/2023, 9:58:48 PM