Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions eagerpy/tensor/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,11 @@ def __ge__(self: TensorType, other: TensorOrScalar) -> TensorType:
def __getitem__(self: TensorType, index: Any) -> TensorType:
if isinstance(index, tuple):
index = tuple(x.raw if isinstance(x, Tensor) else x for x in index)
elif isinstance(index, Tensor):
index = index.raw
else:
if isinstance(index, Tensor):
index = index.raw
if isinstance(index, np.ndarray):
index = torch.as_tensor(index)
return type(self)(self.raw[index])

def take_along_axis(self: TensorType, index: TensorType, axis: int) -> TensorType:
Expand Down