MCPcopy Create free account
hub / github.com/LBANN/lbann / numel

Function numel

ci_test/common_python/test_util.py:314–323  ·  view source on GitHub ↗

Returns the number of elements in a NumPy array, PyTorch array, or integer.

(tensor)

Source from the content-addressed store, hash-verified

312
313
314def numel(tensor) -> int:
315 """
316 Returns the number of elements in a NumPy array, PyTorch array, or integer.
317 """
318 if isinstance(tensor, int): # Integer
319 return tensor
320 elif hasattr(tensor, 'numel'): # PyTorch array
321 return tensor.numel()
322 else: # NumPy array
323 return tensor.size
324
325
326# Mimics the other tester's determination of working directory

Callers 3

make_referenceMethod · 0.85
slice_to_tensorsFunction · 0.85
_ensure_bpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected