MCPcopy Index your code
hub / github.com/apache/tvm / empty

Function empty

python/tvm/runtime/_tensor.py:300–327  ·  view source on GitHub ↗

Create an empty array given shape and device Parameters ---------- shape : Union[tvm_ffi.Shape, Sequence[typing.SupportsInt]] The shape of the array. dtype : type or str The data type of the array. device : Device The device of the array. mem_scope

(shape, dtype="float32", device=None, mem_scope=None)

Source from the content-addressed store, hash-verified

298
299
300def empty(shape, dtype="float32", device=None, mem_scope=None):
301 """Create an empty array given shape and device
302
303 Parameters
304 ----------
305 shape : Union[tvm_ffi.Shape, Sequence[typing.SupportsInt]]
306 The shape of the array.
307
308 dtype : type or str
309 The data type of the array.
310
311 device : Device
312 The device of the array.
313
314 mem_scope : Optional[str]
315 The memory scope of the array.
316
317 Returns
318 -------
319 arr : tvm.runtime.Tensor
320 The array tvm supported.
321 """
322 device = device or cpu()
323 if not isinstance(shape, tvm_ffi.Shape):
324 shape = tvm_ffi.Shape([int(dim) for dim in shape])
325 dtype = tvm_ffi.dtype(dtype)
326 arr = _ffi_api.TVMTensorAllocWithScope(shape, dtype, device, mem_scope)
327 return arr
328
329
330def tensor(arr, device=None, mem_scope=None):

Callers 3

_args_to_deviceFunction · 0.90
copytoMethod · 0.70
tensorFunction · 0.70

Calls 3

cpuFunction · 0.85
ShapeMethod · 0.80
dtypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…