MCPcopy Create free account
hub / github.com/pytorch/pytorch / item

Method item

torch/_numpy/_ndarray.py:410–420  ·  view source on GitHub ↗
(self, *args)

Source from the content-addressed store, hash-verified

408 _funcs.copyto(self, _funcs.sort(self, axis, kind, order))
409
410 def item(self, *args):
411 # Mimic NumPy's implementation with three special cases (no arguments,
412 # a flat index and a multi-index):
413 # https://github.com/numpy/numpy/blob/main/numpy/core/src/multiarray/methods.c#L702
414 if args == ():
415 return self.tensor.item()
416 elif len(args) == 1:
417 # int argument
418 return self.ravel()[args[0]]
419 else:
420 return self.__getitem__(args)
421
422 def __getitem__(self, index):
423 tensor = self.tensor

Callers 15

_getitemMethod · 0.80
_check_tensor_all_withFunction · 0.80
_scalar_strFunction · 0.80
tensordotFunction · 0.80
__format__Method · 0.80
__contains__Method · 0.80
itemFunction · 0.80
narrowFunction · 0.80
istftFunction · 0.80
tensor_splitFunction · 0.80
allcloseFunction · 0.80
hash_storageFunction · 0.80

Calls 1

__getitem__Method · 0.95