Struct opencv::dnn::EinsumLayer
source · pub struct EinsumLayer { /* private fields */ }
Expand description
This function performs array summation based on the Einstein summation convention. The function allows for concise expressions of various mathematical operations using subscripts.
By default, the labels are placed in alphabetical
order at the end of the output.
For example:
if c = einsum("i,j", a, b)
, then c[i,j] == a[i]*b[j]
.
However, if c = einsum("j,i", a, b)
, then c[i,j] = a[j]*b[i]
.
Alternatively, you can control the output order or prevent
an axis from being summed/force an axis to be summed
by providing indices for the output.
For example:
diag(a)
-> einsum("ii->i", a)
sum(a, axis=0)
-> einsum("i...->", a)
Subscripts at the beginning and end may be specified
by putting an ellipsis “…” in the middle.
For instance, the function einsum("i...i", a)
takes
the diagonal of the first and last dimensions of
the operand, and einsum("ij...,jk...->ik...")
performs
the matrix product using the first two indices
of each operand instead of the last two.
When there is only one operand, no axes being summed,
and no output parameter, this function returns
a view into the operand instead of creating a copy.
Implementations§
source§impl EinsumLayer
impl EinsumLayer
pub fn create(params: &impl LayerParamsTraitConst) -> Result<Ptr<EinsumLayer>>
Trait Implementations§
source§impl AlgorithmTrait for EinsumLayer
impl AlgorithmTrait for EinsumLayer
source§impl AlgorithmTraitConst for EinsumLayer
impl AlgorithmTraitConst for EinsumLayer
fn as_raw_Algorithm(&self) -> *const c_void
source§fn write(&self, fs: &mut impl FileStorageTrait) -> Result<()>
fn write(&self, fs: &mut impl FileStorageTrait) -> Result<()>
source§fn write_1(&self, fs: &mut impl FileStorageTrait, name: &str) -> Result<()>
fn write_1(&self, fs: &mut impl FileStorageTrait, name: &str) -> Result<()>
source§fn write_with_name(&self, fs: &Ptr<FileStorage>, name: &str) -> Result<()>
fn write_with_name(&self, fs: &Ptr<FileStorage>, name: &str) -> Result<()>
source§fn write_with_name_def(&self, fs: &Ptr<FileStorage>) -> Result<()>
fn write_with_name_def(&self, fs: &Ptr<FileStorage>) -> Result<()>
§Note
source§fn empty(&self) -> Result<bool>
fn empty(&self) -> Result<bool>
source§fn save(&self, filename: &str) -> Result<()>
fn save(&self, filename: &str) -> Result<()>
source§fn get_default_name(&self) -> Result<String>
fn get_default_name(&self) -> Result<String>
source§impl Boxed for EinsumLayer
impl Boxed for EinsumLayer
source§unsafe fn from_raw(
ptr: <EinsumLayer as OpenCVFromExtern>::ExternReceive
) -> Self
unsafe fn from_raw( ptr: <EinsumLayer as OpenCVFromExtern>::ExternReceive ) -> Self
source§fn into_raw(self) -> <EinsumLayer as OpenCVTypeExternContainer>::ExternSendMut
fn into_raw(self) -> <EinsumLayer as OpenCVTypeExternContainer>::ExternSendMut
source§fn as_raw(&self) -> <EinsumLayer as OpenCVTypeExternContainer>::ExternSend
fn as_raw(&self) -> <EinsumLayer as OpenCVTypeExternContainer>::ExternSend
source§fn as_raw_mut(
&mut self
) -> <EinsumLayer as OpenCVTypeExternContainer>::ExternSendMut
fn as_raw_mut( &mut self ) -> <EinsumLayer as OpenCVTypeExternContainer>::ExternSendMut
source§impl Debug for EinsumLayer
impl Debug for EinsumLayer
source§impl Default for EinsumLayer
impl Default for EinsumLayer
source§impl Drop for EinsumLayer
impl Drop for EinsumLayer
source§impl EinsumLayerTrait for EinsumLayer
impl EinsumLayerTrait for EinsumLayer
fn as_raw_mut_EinsumLayer(&mut self) -> *mut c_void
source§impl EinsumLayerTraitConst for EinsumLayer
impl EinsumLayerTraitConst for EinsumLayer
fn as_raw_EinsumLayer(&self) -> *const c_void
source§impl From<EinsumLayer> for Algorithm
impl From<EinsumLayer> for Algorithm
source§fn from(s: EinsumLayer) -> Self
fn from(s: EinsumLayer) -> Self
source§impl From<EinsumLayer> for Layer
impl From<EinsumLayer> for Layer
source§fn from(s: EinsumLayer) -> Self
fn from(s: EinsumLayer) -> Self
source§impl LayerTrait for EinsumLayer
impl LayerTrait for EinsumLayer
fn as_raw_mut_Layer(&mut self) -> *mut c_void
source§fn set_blobs(&mut self, val: Vector<Mat>)
fn set_blobs(&mut self, val: Vector<Mat>)
source§fn set_name(&mut self, val: &str)
fn set_name(&mut self, val: &str)
source§fn set_type(&mut self, val: &str)
fn set_type(&mut self, val: &str)
source§fn set_preferable_target(&mut self, val: i32)
fn set_preferable_target(&mut self, val: i32)
source§fn finalize(
&mut self,
inputs: &impl ToInputArray,
outputs: &mut impl ToOutputArray
) -> Result<()>
fn finalize( &mut self, inputs: &impl ToInputArray, outputs: &mut impl ToOutputArray ) -> Result<()>
source§fn forward_mat(
&mut self,
input: &mut Vector<Mat>,
output: &mut Vector<Mat>,
internals: &mut Vector<Mat>
) -> Result<()>
fn forward_mat( &mut self, input: &mut Vector<Mat>, output: &mut Vector<Mat>, internals: &mut Vector<Mat> ) -> Result<()>
source§fn forward(
&mut self,
inputs: &impl ToInputArray,
outputs: &mut impl ToOutputArray,
internals: &mut impl ToOutputArray
) -> Result<()>
fn forward( &mut self, inputs: &impl ToInputArray, outputs: &mut impl ToOutputArray, internals: &mut impl ToOutputArray ) -> Result<()>
source§fn try_quantize(
&mut self,
scales: &Vector<Vector<f32>>,
zeropoints: &Vector<Vector<i32>>,
params: &mut impl LayerParamsTrait
) -> Result<bool>
fn try_quantize( &mut self, scales: &Vector<Vector<f32>>, zeropoints: &Vector<Vector<i32>>, params: &mut impl LayerParamsTrait ) -> Result<bool>
source§fn forward_fallback(
&mut self,
inputs: &impl ToInputArray,
outputs: &mut impl ToOutputArray,
internals: &mut impl ToOutputArray
) -> Result<()>
fn forward_fallback( &mut self, inputs: &impl ToInputArray, outputs: &mut impl ToOutputArray, internals: &mut impl ToOutputArray ) -> Result<()>
source§fn finalize_mat_to(
&mut self,
inputs: &Vector<Mat>,
outputs: &mut Vector<Mat>
) -> Result<()>
fn finalize_mat_to( &mut self, inputs: &Vector<Mat>, outputs: &mut Vector<Mat> ) -> Result<()>
source§fn finalize_mat(&mut self, inputs: &Vector<Mat>) -> Result<Vector<Mat>>
fn finalize_mat(&mut self, inputs: &Vector<Mat>) -> Result<Vector<Mat>>
source§fn run(
&mut self,
inputs: &Vector<Mat>,
outputs: &mut Vector<Mat>,
internals: &mut Vector<Mat>
) -> Result<()>
fn run( &mut self, inputs: &Vector<Mat>, outputs: &mut Vector<Mat>, internals: &mut Vector<Mat> ) -> Result<()>
source§fn input_name_to_index(&mut self, input_name: &str) -> Result<i32>
fn input_name_to_index(&mut self, input_name: &str) -> Result<i32>
source§fn output_name_to_index(&mut self, output_name: &str) -> Result<i32>
fn output_name_to_index(&mut self, output_name: &str) -> Result<i32>
source§fn support_backend(&mut self, backend_id: i32) -> Result<bool>
fn support_backend(&mut self, backend_id: i32) -> Result<bool>
source§fn init_halide(
&mut self,
inputs: &Vector<Ptr<BackendWrapper>>
) -> Result<Ptr<BackendNode>>
fn init_halide( &mut self, inputs: &Vector<Ptr<BackendWrapper>> ) -> Result<Ptr<BackendNode>>
fn init_ngraph( &mut self, inputs: &Vector<Ptr<BackendWrapper>>, nodes: &Vector<Ptr<BackendNode>> ) -> Result<Ptr<BackendNode>>
fn init_vk_com( &mut self, inputs: &Vector<Ptr<BackendWrapper>>, outputs: &mut Vector<Ptr<BackendWrapper>> ) -> Result<Ptr<BackendNode>>
fn init_webnn( &mut self, inputs: &Vector<Ptr<BackendWrapper>>, nodes: &Vector<Ptr<BackendNode>> ) -> Result<Ptr<BackendNode>>
source§unsafe fn init_cuda(
&mut self,
context: *mut c_void,
inputs: &Vector<Ptr<BackendWrapper>>,
outputs: &Vector<Ptr<BackendWrapper>>
) -> Result<Ptr<BackendNode>>
unsafe fn init_cuda( &mut self, context: *mut c_void, inputs: &Vector<Ptr<BackendWrapper>>, outputs: &Vector<Ptr<BackendWrapper>> ) -> Result<Ptr<BackendNode>>
source§unsafe fn init_tim_vx(
&mut self,
tim_vx_info: *mut c_void,
inputs_wrapper: &Vector<Ptr<BackendWrapper>>,
outputs_wrapper: &Vector<Ptr<BackendWrapper>>,
is_last: bool
) -> Result<Ptr<BackendNode>>
unsafe fn init_tim_vx( &mut self, tim_vx_info: *mut c_void, inputs_wrapper: &Vector<Ptr<BackendWrapper>>, outputs_wrapper: &Vector<Ptr<BackendWrapper>>, is_last: bool ) -> Result<Ptr<BackendNode>>
source§fn init_cann(
&mut self,
inputs: &Vector<Ptr<BackendWrapper>>,
outputs: &Vector<Ptr<BackendWrapper>>,
nodes: &Vector<Ptr<BackendNode>>
) -> Result<Ptr<BackendNode>>
fn init_cann( &mut self, inputs: &Vector<Ptr<BackendWrapper>>, outputs: &Vector<Ptr<BackendWrapper>>, nodes: &Vector<Ptr<BackendNode>> ) -> Result<Ptr<BackendNode>>
source§fn try_attach(&mut self, node: &Ptr<BackendNode>) -> Result<Ptr<BackendNode>>
fn try_attach(&mut self, node: &Ptr<BackendNode>) -> Result<Ptr<BackendNode>>
source§fn set_activation(&mut self, layer: &Ptr<ActivationLayer>) -> Result<bool>
fn set_activation(&mut self, layer: &Ptr<ActivationLayer>) -> Result<bool>
source§fn try_fuse(&mut self, top: &mut Ptr<Layer>) -> Result<bool>
fn try_fuse(&mut self, top: &mut Ptr<Layer>) -> Result<bool>
source§fn unset_attached(&mut self) -> Result<()>
fn unset_attached(&mut self) -> Result<()>
fn update_memory_shapes(&mut self, inputs: &Vector<MatShape>) -> Result<bool>
fn set_params_from(&mut self, params: &impl LayerParamsTraitConst) -> Result<()>
source§impl LayerTraitConst for EinsumLayer
impl LayerTraitConst for EinsumLayer
fn as_raw_Layer(&self) -> *const c_void
source§fn blobs(&self) -> Vector<Mat>
fn blobs(&self) -> Vector<Mat>
source§fn name(&self) -> String
fn name(&self) -> String
source§fn preferable_target(&self) -> i32
fn preferable_target(&self) -> i32
source§fn apply_halide_scheduler(
&self,
node: &mut Ptr<BackendNode>,
inputs: &Vector<Mat>,
outputs: &Vector<Mat>,
target_id: i32
) -> Result<()>
fn apply_halide_scheduler( &self, node: &mut Ptr<BackendNode>, inputs: &Vector<Mat>, outputs: &Vector<Mat>, target_id: i32 ) -> Result<()>
source§fn get_scale_shift(
&self,
scale: &mut impl MatTrait,
shift: &mut impl MatTrait
) -> Result<()>
fn get_scale_shift( &self, scale: &mut impl MatTrait, shift: &mut impl MatTrait ) -> Result<()>
source§fn get_scale_zeropoint(
&self,
scale: &mut f32,
zeropoint: &mut i32
) -> Result<()>
fn get_scale_zeropoint( &self, scale: &mut f32, zeropoint: &mut i32 ) -> Result<()>
fn get_memory_shapes( &self, inputs: &Vector<MatShape>, required_outputs: i32, outputs: &mut Vector<MatShape>, internals: &mut Vector<MatShape> ) -> Result<bool>
fn get_flops( &self, inputs: &Vector<MatShape>, outputs: &Vector<MatShape> ) -> Result<i64>
source§impl TryFrom<Layer> for EinsumLayer
impl TryFrom<Layer> for EinsumLayer
impl Send for EinsumLayer
Auto Trait Implementations§
impl Freeze for EinsumLayer
impl RefUnwindSafe for EinsumLayer
impl !Sync for EinsumLayer
impl Unpin for EinsumLayer
impl UnwindSafe for EinsumLayer
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
source§impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
source§unsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Mat, &mut Mat) -> Res
) -> Res
unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res ) -> Res
Mat
or another similar object. By passing
a mutable reference to the Mat
to this function your closure will get called with the read reference and a write references
to the same Mat
. This is of course unsafe as it breaks the Rust aliasing rules, but it might be useful for some performance
sensitive operations. One example of an OpenCV function that allows such in-place modification is imgproc::threshold
. Read more