Load all tensors as a HashMap suitable for VarBuilder::from_tensors().
(
&self,
dtype: candle_core::DType,
device: &candle_core::Device,
)
| 294 | |
| 295 | /// Load all tensors as a HashMap suitable for VarBuilder::from_tensors(). |
| 296 | pub fn load_all( |
| 297 | &self, |
| 298 | dtype: candle_core::DType, |
| 299 | device: &candle_core::Device, |
| 300 | ) -> Result<HashMap<String, candle_core::Tensor>> { |
| 301 | let mut map = HashMap::with_capacity(self.index.len()); |
| 302 | for name in self.index.keys() { |
| 303 | let tensor = self.load_tensor(name, dtype, device)?; |
| 304 | map.insert(name.clone(), tensor); |
| 305 | } |
| 306 | Ok(map) |
| 307 | } |
| 308 | |
| 309 | /// Build from a multi-shard model with index JSON. |
| 310 | fn from_index_json(index_path: &Path) -> Result<Self> { |