burn_tensor/tensor/quantization/
calibration.rs1use crate::{backend::Backend, Tensor};
2
3#[derive(Clone, Debug)]
5pub struct CalibrationRange<B: Backend> {
6 pub min: Tensor<B, 1>,
8 pub max: Tensor<B, 1>,
10}
11
12pub trait Calibration {
14 fn compute_range<B: Backend, const D: usize>(
16 &self,
17 tensor: &Tensor<B, D>,
18 ) -> CalibrationRange<B>;
19}
20
21pub struct MinMaxCalibration {}
23
24impl Calibration for MinMaxCalibration {
25 fn compute_range<B: Backend, const D: usize>(
26 &self,
27 tensor: &Tensor<B, D>,
28 ) -> CalibrationRange<B> {
29 let min = tensor.clone().min();
30 let max = tensor.clone().max();
31
32 CalibrationRange { min, max }
33 }
34}