pub struct GgmlContext { /* private fields */ }Expand description
A safe wrapper around ggml_context.
Implementations§
Source§impl GgmlContext
impl GgmlContext
Sourcepub fn as_ptr(&self) -> *mut ggml_context
pub fn as_ptr(&self) -> *mut ggml_context
Get the raw context pointer.
Sourcepub fn new_tensor_1d(&self, typ: ggml_type, ne0: i64) -> GgmlTensor
pub fn new_tensor_1d(&self, typ: ggml_type, ne0: i64) -> GgmlTensor
Create a 1D tensor.
Sourcepub fn new_tensor_2d(&self, typ: ggml_type, ne0: i64, ne1: i64) -> GgmlTensor
pub fn new_tensor_2d(&self, typ: ggml_type, ne0: i64, ne1: i64) -> GgmlTensor
Create a 2D tensor.
Sourcepub fn new_tensor_3d(
&self,
typ: ggml_type,
ne0: i64,
ne1: i64,
ne2: i64,
) -> GgmlTensor
pub fn new_tensor_3d( &self, typ: ggml_type, ne0: i64, ne1: i64, ne2: i64, ) -> GgmlTensor
Create a 3D tensor.
Sourcepub fn new_tensor_4d(
&self,
typ: ggml_type,
ne0: i64,
ne1: i64,
ne2: i64,
ne3: i64,
) -> GgmlTensor
pub fn new_tensor_4d( &self, typ: ggml_type, ne0: i64, ne1: i64, ne2: i64, ne3: i64, ) -> GgmlTensor
Create a 4D tensor.
Sourcepub fn dup_tensor(&self, src: &GgmlTensor) -> GgmlTensor
pub fn dup_tensor(&self, src: &GgmlTensor) -> GgmlTensor
Create a tensor with the same shape and type as another.
Sourcepub fn new_tensor(&self, typ: ggml_type, ne: &[i64]) -> GgmlTensor
pub fn new_tensor(&self, typ: ggml_type, ne: &[i64]) -> GgmlTensor
Create a new tensor with arbitrary dimensions.
Sourcepub fn add(&self, a: &GgmlTensor, b: &GgmlTensor) -> GgmlTensor
pub fn add(&self, a: &GgmlTensor, b: &GgmlTensor) -> GgmlTensor
Element-wise addition: a + b
Sourcepub fn mul_mat(&self, a: &GgmlTensor, b: &GgmlTensor) -> GgmlTensor
pub fn mul_mat(&self, a: &GgmlTensor, b: &GgmlTensor) -> GgmlTensor
Matrix multiplication: a @ b
Sourcepub fn scale(&self, a: &GgmlTensor, s: f32) -> GgmlTensor
pub fn scale(&self, a: &GgmlTensor, s: f32) -> GgmlTensor
Scale tensor: a * s
Sourcepub fn cast(&self, a: &GgmlTensor, typ: ggml_type) -> GgmlTensor
pub fn cast(&self, a: &GgmlTensor, typ: ggml_type) -> GgmlTensor
Cast tensor to a different type.
Sourcepub fn cont(&self, a: &GgmlTensor) -> GgmlTensor
pub fn cont(&self, a: &GgmlTensor) -> GgmlTensor
Make tensor contiguous in memory.
Sourcepub fn transpose(&self, a: &GgmlTensor) -> GgmlTensor
pub fn transpose(&self, a: &GgmlTensor) -> GgmlTensor
Transpose a tensor.
Sourcepub fn reshape_1d(&self, a: &GgmlTensor, ne0: i64) -> GgmlTensor
pub fn reshape_1d(&self, a: &GgmlTensor, ne0: i64) -> GgmlTensor
Reshape to 1D.
Sourcepub fn reshape_2d(&self, a: &GgmlTensor, ne0: i64, ne1: i64) -> GgmlTensor
pub fn reshape_2d(&self, a: &GgmlTensor, ne0: i64, ne1: i64) -> GgmlTensor
Reshape to 2D.
Sourcepub fn view_1d(&self, a: &GgmlTensor, ne0: i64, offset: usize) -> GgmlTensor
pub fn view_1d(&self, a: &GgmlTensor, ne0: i64, offset: usize) -> GgmlTensor
Create a 1D view of a tensor.
Sourcepub fn first_tensor(&self) -> Option<GgmlTensor>
pub fn first_tensor(&self) -> Option<GgmlTensor>
Get the first tensor in this context.
Sourcepub fn next_tensor(&self, tensor: &GgmlTensor) -> Option<GgmlTensor>
pub fn next_tensor(&self, tensor: &GgmlTensor) -> Option<GgmlTensor>
Get the next tensor after tensor in this context.
Trait Implementations§
Source§impl Debug for GgmlContext
impl Debug for GgmlContext
Auto Trait Implementations§
impl Freeze for GgmlContext
impl RefUnwindSafe for GgmlContext
impl !Send for GgmlContext
impl !Sync for GgmlContext
impl Unpin for GgmlContext
impl UnsafeUnpin for GgmlContext
impl UnwindSafe for GgmlContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more