pub fn empty(
shape: &[i64],
dtype: DLDataType,
device: DLDevice,
mem_scope: Option<&MemoryScope>,
) -> Result<Tensor>Expand description
Allocate an uninitialized tensor on device, in the memory scope mem_scope or the global one
(runtime.TensorAllocWithScope).
§Errors
Returns an error if the allocator of device does not support mem_scope; the CPU one supports
only the global scope.
§Examples
use tvm_tirx::ir::dtype;
use tvm_tirx::runtime;
use tvm_tirx::tvm_ffi::{DLDevice, DLDeviceType};
let cpu = DLDevice::new(DLDeviceType::kDLCPU, 0);
let buffer = runtime::empty(&[2, 8], dtype::float(32), cpu, None)?;
let bytes = runtime::create_view(&buffer, &[64], dtype::int(8), 0)?;
assert_eq!(bytes.shape(), &[64]);