MCPcopy Create free account
hub / github.com/NVIDIA/DALI / to_numpy

Method to_numpy

dali/python/nvidia/dali/_tensor_formatting.py:226–239  ·  view source on GitHub ↗
(self, obj, edgeitems=None)

Source from the content-addressed store, hash-verified

224 return obj.tensors[index]
225
226 def to_numpy(self, obj, edgeitems=None):
227 cpu_obj = self.to_cpu(obj)
228 length = cpu_obj.batch_size
229
230 if length == 0:
231 return []
232
233 # Determine which samples to convert
234 if edgeitems is not None and length > 2 * edgeitems + 1:
235 indices = list(range(edgeitems)) + list(range(length - edgeitems, length))
236 else:
237 indices = range(length)
238
239 return [np.array(cpu_obj.tensors[i]) for i in indices]
240
241
242def format_tensor(obj, show_data: bool = True, adapter: Optional[TensorAdapter] = None) -> str:

Callers

nothing calls this directly

Calls 1

to_cpuMethod · 0.45

Tested by

no test coverage detected