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,
)
| 21 | |
| 22 | |
| 23 | def 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 | |
| 62 | def alloc_tensor( |
nothing calls this directly
no test coverage detected
searching dependent graphs…