MCPcopy Create free account
hub / github.com/apache/tvm / alloc_storage

Function alloc_storage

python/tvm/relax/op/memory/memory.py:23–59  ·  view source on GitHub ↗

Construct a Call to allocate a storage with specific size, virtual_device_index, storage_scope and dtype. Parameters ---------- size : Expr The size of the storage to be allocated. virtual_device_index : Union[int, Expr] The virtual device index indicating on wh

(
    size: Expr,
    virtual_device_index: int | Expr,
    storage_scope: str | Expr,
    dtype: str | Expr,
)

Source from the content-addressed store, hash-verified

21
22
23def alloc_storage(
24 size: Expr,
25 virtual_device_index: int | Expr,
26 storage_scope: str | Expr,
27 dtype: str | Expr,
28) -> Call:
29 """Construct a Call to allocate a storage with specific size, virtual_device_index,
30 storage_scope and dtype.
31
32 Parameters
33 ----------
34 size : Expr
35 The size of the storage to be allocated.
36
37 virtual_device_index : Union[int, Expr]
38 The virtual device index indicating on which device the storage is to be allocated.
39 Index -1 is reserved for the host device.
40
41 storage_scope : Union[str, Expr]
42 The storage scope to allocate the storage to.
43
44 dtype : Union[str, Expr]
45 The datatype of the storage to be allocated.
46
47 Returns
48 -------
49 result : Call
50 A relax Call, which gets the allocated storage.
51 """
52 size = convert_to_expr(size)
53 if isinstance(dtype, str):
54 dtype = DataTypeImm(dtype)
55 if isinstance(storage_scope, str):
56 storage_scope = StringImm(storage_scope)
57 if isinstance(virtual_device_index, int):
58 virtual_device_index = PrimValue(virtual_device_index)
59 return _ffi_api.alloc_storage(size, virtual_device_index, storage_scope, dtype) # type: ignore
60
61
62def alloc_tensor(

Callers

nothing calls this directly

Calls 4

convert_to_exprFunction · 0.85
DataTypeImmClass · 0.85
PrimValueClass · 0.85
StringImmClass · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…