pub mod helper;
pub(crate) mod kernels;
pub(crate) mod outputs;
pub(crate) mod pipeline;
pub(crate) mod plan;
pub use helper::apply_schema_quant;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum DecodeDtype {
#[default]
F32,
F16,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[allow(dead_code)] pub(crate) enum Activation {
#[default]
None,
Sigmoid,
}
impl Activation {
#[allow(dead_code)] pub(crate) fn from_schema(s: Option<crate::schema::Activation>) -> Self {
match s {
Some(crate::schema::Activation::Sigmoid) => Self::Sigmoid,
_ => Self::None,
}
}
}
pub(crate) use outputs::{DecodedOutputBuffers, DecodedOutputsRef};
pub(crate) use plan::PerScalePlan;
#[derive(Debug)]
#[allow(dead_code)] pub(crate) struct PerScaleDecoder {
pub(crate) plan: PerScalePlan,
pub(crate) buffers: DecodedOutputBuffers,
}
impl PerScaleDecoder {
#[allow(dead_code)] pub(crate) fn new(plan: PerScalePlan) -> Self {
let buffers = DecodedOutputBuffers::new(
plan.out_dtype,
plan.total_anchors,
plan.num_classes,
plan.num_mask_coefs,
plan.proto_nhwc_shape.as_deref(),
);
Self { plan, buffers }
}
#[allow(dead_code)] pub(crate) fn run<'a>(
&'a mut self,
inputs: &[&edgefirst_tensor::TensorDyn],
) -> crate::DecoderResult<DecodedOutputsRef<'a>> {
pipeline::run(&self.plan, &mut self.buffers, inputs)
}
}
#[doc(hidden)]
pub struct PreNmsCapture {
pub boxes_xywh: ndarray::Array2<f32>,
pub scores: ndarray::Array2<f32>,
pub mask_coefs: Option<ndarray::Array2<f32>>,
pub protos: Option<ndarray::Array4<f32>>,
}