pub trait ComputeLayer<F: Field> {
type DevMem: ComputeMemory<F>;
type Exec<'a>: ComputeLayerExecutor<F, DevMem = Self::DevMem>
where Self: 'a;
// Required methods
fn copy_h2d(
&self,
src: &[F],
dst: &mut FSliceMut<'_, F, Self>,
) -> Result<(), Error>;
fn copy_d2h(
&self,
src: FSlice<'_, F, Self>,
dst: &mut [F],
) -> Result<(), Error>;
fn copy_d2d(
&self,
src: FSlice<'_, F, Self>,
dst: &mut FSliceMut<'_, F, Self>,
) -> Result<(), Error>;
fn compile_expr(
&self,
expr: &ArithCircuit<F>,
) -> Result<<Self::Exec<'_> as ComputeLayerExecutor<F>>::ExprEval, Error>;
fn execute<'a, 'b>(
&'b self,
f: impl FnOnce(&mut Self::Exec<'a>) -> Result<Vec<<Self::Exec<'a> as ComputeLayerExecutor<F>>::OpValue>, Error>,
) -> Result<Vec<F>, Error>
where 'b: 'a;
fn fill(
&self,
slice: &mut <Self::DevMem as ComputeMemory<F>>::FSliceMut<'_>,
value: F,
) -> Result<(), Error>;
}
Expand description
A hardware abstraction layer (HAL) for compute operations.
Required Associated Types§
Sourcetype DevMem: ComputeMemory<F>
type DevMem: ComputeMemory<F>
The device memory.
Sourcetype Exec<'a>: ComputeLayerExecutor<F, DevMem = Self::DevMem>
where
Self: 'a
type Exec<'a>: ComputeLayerExecutor<F, DevMem = Self::DevMem> where Self: 'a
The executor that can execute operations on the device.
Required Methods§
Sourcefn copy_d2d(
&self,
src: FSlice<'_, F, Self>,
dst: &mut FSliceMut<'_, F, Self>,
) -> Result<(), Error>
fn copy_d2d( &self, src: FSlice<'_, F, Self>, dst: &mut FSliceMut<'_, F, Self>, ) -> Result<(), Error>
Sourcefn compile_expr(
&self,
expr: &ArithCircuit<F>,
) -> Result<<Self::Exec<'_> as ComputeLayerExecutor<F>>::ExprEval, Error>
fn compile_expr( &self, expr: &ArithCircuit<F>, ) -> Result<<Self::Exec<'_> as ComputeLayerExecutor<F>>::ExprEval, Error>
Compiles an arithmetic expression to the evaluator.
Sourcefn execute<'a, 'b>(
&'b self,
f: impl FnOnce(&mut Self::Exec<'a>) -> Result<Vec<<Self::Exec<'a> as ComputeLayerExecutor<F>>::OpValue>, Error>,
) -> Result<Vec<F>, Error>where
'b: 'a,
fn execute<'a, 'b>(
&'b self,
f: impl FnOnce(&mut Self::Exec<'a>) -> Result<Vec<<Self::Exec<'a> as ComputeLayerExecutor<F>>::OpValue>, Error>,
) -> Result<Vec<F>, Error>where
'b: 'a,
Executes an operation.
A HAL operation is an abstract function that runs with an executor reference.
Sourcefn fill(
&self,
slice: &mut <Self::DevMem as ComputeMemory<F>>::FSliceMut<'_>,
value: F,
) -> Result<(), Error>
fn fill( &self, slice: &mut <Self::DevMem as ComputeMemory<F>>::FSliceMut<'_>, value: F, ) -> Result<(), Error>
Fills a mutable slice of field elements with a given value.
This operation takes a mutable slice (FSliceMut<F>
) and a field element value
,
and sets each element in the slice to the given value.
§Arguments
slice
- A mutable slice of field elements to be filled.value
- The field element used to fill each position in the slice.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.