From 6f0fbc8a3db8351f04664c5347ac53afd1a37694 Mon Sep 17 00:00:00 2001 From: tmontaigu Date: Thu, 12 Jan 2023 11:19:57 +0100 Subject: [PATCH] feat(rust): add from_tensor_[u32|u16] --- compiler/lib/Bindings/Rust/src/compiler.rs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/compiler/lib/Bindings/Rust/src/compiler.rs b/compiler/lib/Bindings/Rust/src/compiler.rs index 87d7d14e7..cca234590 100644 --- a/compiler/lib/Bindings/Rust/src/compiler.rs +++ b/compiler/lib/Bindings/Rust/src/compiler.rs @@ -781,6 +781,34 @@ impl LambdaArgument { } } + pub fn from_tensor_u16(data: &[u16], dims: &[i64]) -> Result { + unsafe { + let arg = LambdaArgument::wrap(ffi::lambdaArgumentFromTensorU16( + data.as_ptr(), + dims.as_ptr(), + dims.len().try_into().unwrap(), + )); + if arg.is_null() { + return Err(CompilerError(arg.error_msg())); + } + Ok(arg) + } + } + + pub fn from_tensor_u32(data: &[u32], dims: &[i64]) -> Result { + unsafe { + let arg = LambdaArgument::wrap(ffi::lambdaArgumentFromTensorU32( + data.as_ptr(), + dims.as_ptr(), + dims.len().try_into().unwrap(), + )); + if arg.is_null() { + return Err(CompilerError(arg.error_msg())); + } + Ok(arg) + } + } + pub fn from_tensor_u64(data: &[u64], dims: &[i64]) -> Result { unsafe { let arg = LambdaArgument::wrap(ffi::lambdaArgumentFromTensorU64(