pub struct BackendOptions {
pub opt_level: u8,
pub symbolic_extent: Option<u32>,
pub precision: PrecisionPolicy,
pub memory_plan: Option<MemoryPlan>,
pub quantization_params: Vec<QuantParam>,
pub per_channel_params: Vec<PerChannelParam>,
pub tiling_plans: Vec<TilingPlanInfo>,
pub vectorization_hints: Vec<VectorizationHintInfo>,
pub constant_tensors: Vec<ConstantTensor>,
}Expand description
Options passed to a backend during compilation.
The precision field controls the target quantization precision.
In the typical workflow, the caller (e.g. nxpu-cli) applies the
appropriate quantization pass (F32ToF16, F32ToBf16, F32ToInt8,
or MixedPrecisionPass) to the IR module before calling
Backend::compile. The precision field is informational — backends
can read it to emit diagnostics or choose format-specific options,
but the IR has already been rewritten by the quantization pass.
Fields§
§opt_level: u8Optimization level (0 = none, 1 = basic, 2 = aggressive).
symbolic_extent: Option<u32>Concrete extent to substitute for tensor dimensions the kernel leaves symbolic.
A WGSL kernel over array<f32> carries no length, so the emitted graph
has no size for most dimensions. Formats differ on what to do about
that: ONNX names them and resolves later, while TFLite requires a
concrete extent and cannot load a model without one. None means the
caller did not say, and the backend picks the smallest valid extent.
The type forbids a negative value on purpose: writing -1 here is the
bug that made every TFLite model this project emitted unloadable.
precision: PrecisionPolicyPrecision policy for quantization.
The CLI applies the corresponding quantization pass to the IR before compilation. Backends may use this to emit precision-related diagnostics or metadata, but should not re-quantize the IR.
memory_plan: Option<MemoryPlan>Optional memory plan computed by the memory planning pass.
When present, backends can use this to emit buffer allocation metadata
(e.g. ONNX metadata_props, TFLite buffer info). Backends that do not
support memory plan metadata may ignore this field.
quantization_params: Vec<QuantParam>Optional per-tensor quantization parameters from calibration.
When present, backends embed these parameters in the compiled output
(e.g. ONNX metadata_props, TFLite companion JSON) so downstream
tools can correctly dequantize tensors.
per_channel_params: Vec<PerChannelParam>Per-channel quantization parameters for weight tensors.
When present, backends emit per-channel quantization metadata: ONNX backends inject QuantizeLinear/DequantizeLinear (QDQ) nodes, TFLite backends include them in the companion JSON.
tiling_plans: Vec<TilingPlanInfo>Tiling plans computed by the tiling pass.
Backends may use these to emit cache-blocking metadata or generate tiled loop structures.
vectorization_hints: Vec<VectorizationHintInfo>Vectorization hints computed by the vectorization pass.
Backends may use these to emit SIMD annotations or select vector instruction widths.
constant_tensors: Vec<ConstantTensor>Contents for tensors the kernel receives as buffers, by name.
A WGSL kernel takes its weights through var<storage, read> and there
is nothing in the source to say what they are — the host binds them per
dispatch. An NNAPI driver will not accept a convolution on those terms:
measured on a MediaTek MT6899, mtk-neuron_shim accelerates a
convolution whose filter is a compile-time constant and refuses the
identical convolution, at the same shapes, whose filter is a graph
input.
A tensor named here is emitted as a constant and stops being a graph input. Empty is not “fill it with zeros”: a model that accelerated because its weights were invented would run, be attributed to the accelerator, and compute the wrong thing.
Trait Implementations§
Source§impl Clone for BackendOptions
impl Clone for BackendOptions
Source§fn clone(&self) -> BackendOptions
fn clone(&self) -> BackendOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more