(
&self,
s: Shape,
name: &str,
_h: Init,
dtype: DType,
dev: &Device,
)
| 192 | |
| 193 | impl SimpleBackend for GgufBackend { |
| 194 | fn get( |
| 195 | &self, |
| 196 | s: Shape, |
| 197 | name: &str, |
| 198 | _h: Init, |
| 199 | dtype: DType, |
| 200 | dev: &Device, |
| 201 | ) -> candle_core::Result<Tensor> { |
| 202 | let tensor = self |
| 203 | .tensors |
| 204 | .get(name) |
| 205 | .ok_or_else(|| { |
| 206 | candle_core::Error::CannotFindTensor { |
| 207 | path: name.to_string(), |
| 208 | } |
| 209 | .bt() |
| 210 | })? |
| 211 | .to_dtype(dtype)? |
| 212 | .to_device(dev)?; |
| 213 | if tensor.shape() != &s { |
| 214 | Err(candle_core::Error::UnexpectedShape { |
| 215 | msg: format!("shape mismatch for {name}"), |
| 216 | expected: s, |
| 217 | got: tensor.shape().clone(), |
| 218 | } |
| 219 | .bt())? |
| 220 | } |
| 221 | Ok(tensor) |
| 222 | } |
| 223 | |
| 224 | fn get_unchecked( |
| 225 | &self, |
no test coverage detected