MCPcopy
hub / github.com/apache/tvm / tensor

Function tensor

python/tvm/runtime/_tensor.py:330–353  ·  view source on GitHub ↗

Create an tensor from source arr. Parameters ---------- arr : numpy.ndarray The array to be copied from device : Device, optional The device to create the array mem_scope : Optional[str] The memory scope of the array Returns ------- ret : T

(arr, device=None, mem_scope=None)

Source from the content-addressed store, hash-verified

328
329
330def tensor(arr, device=None, mem_scope=None):
331 """Create an tensor from source arr.
332
333 Parameters
334 ----------
335 arr : numpy.ndarray
336 The array to be copied from
337
338 device : Device, optional
339 The device to create the array
340
341 mem_scope : Optional[str]
342 The memory scope of the array
343
344 Returns
345 -------
346 ret : Tensor
347 The created array
348 """
349 device = device or cpu()
350
351 if not isinstance(arr, np.ndarray | Tensor):
352 arr = np.asarray(arr)
353 return empty(arr.shape, arr.dtype, device, mem_scope).copyfrom(arr)
354
355
356def cpu(dev_id=0):

Callers 2

_add_one_tensorFunction · 0.90
_to_tensorFunction · 0.85

Calls 3

cpuFunction · 0.85
copyfromMethod · 0.80
emptyFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…