Create an Fp8Linear from a VarBuilder (no bias).
(
in_features: usize,
out_features: usize,
vb: candle_nn::VarBuilder,
)
| 245 | |
| 246 | /// Create an Fp8Linear from a VarBuilder (no bias). |
| 247 | pub fn fp8_linear( |
| 248 | in_features: usize, |
| 249 | out_features: usize, |
| 250 | vb: candle_nn::VarBuilder, |
| 251 | ) -> candle_core::Result<Fp8Linear> { |
| 252 | let weight = vb.get_unchecked_dtype("weight", candle_core::DType::F32)?; |
| 253 | if weight.dims().len() == 2 && weight.dim(0)? == out_features && weight.dim(1)? == in_features { |
| 254 | Ok(Fp8Linear::new(weight, None)) |
| 255 | } else if weight.dims().len() == 2 |
| 256 | && weight.dim(0)? == in_features |
| 257 | && weight.dim(1)? == out_features |
| 258 | { |
| 259 | Ok(Fp8Linear::new(weight.t()?, None)) |
| 260 | } else { |
| 261 | Ok(Fp8Linear::new(weight, None)) |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | /// Create an Fp8Linear from a VarBuilder (with bias). |
| 266 | pub fn fp8_linear_b( |
no outgoing calls