use core::marker::PhantomData;
use executorch_sys as sys;
use crate::tensor::ScalarType;
use crate::util::{IntoRust, __ArrayRefImpl};
#[repr(transparent)]
pub struct TensorLayout<'a>(sys::TensorLayout, PhantomData<&'a ()>);
impl<'a> TensorLayout<'a> {
pub(crate) unsafe fn from_raw(raw: sys::TensorLayout) -> TensorLayout<'a> {
Self(raw, PhantomData)
}
pub fn sizes(&self) -> &[i32] {
unsafe { sys::executorch_TensorLayout_sizes(&self.0 as *const _).as_slice() }
}
pub fn dim_order(&self) -> &[u8] {
unsafe { sys::executorch_TensorLayout_dim_order(&self.0 as *const _).as_slice() }
}
pub fn scalar_type(&self) -> ScalarType {
unsafe { sys::executorch_TensorLayout_scalar_type(&self.0 as *const _) }.rs()
}
pub fn nbytes(&self) -> usize {
unsafe { sys::executorch_TensorLayout_nbytes(&self.0 as *const _) }
}
}