Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

replace panic with error

eugene2818c6324874
diff --git a/crates/uzu/src/array.rs b/crates/uzu/src/array.rs
index fc37e3bf7..851f3f337 100644
--- a/crates/uzu/src/array.rs
+++ b/crates/uzu/src/array.rs
@@ -118,7 +118,7 @@ pub trait Array {
/// Returns an error if the requested type does not match the array's data type.
fn as_view<T: ArrayElement>(
&self
- ) -> Result<ArrayView<T, IxDyn>, ArrayConversionError> {
+ ) -> Result<ArrayView<'_, T, IxDyn>, ArrayConversionError> {
Ok(ArrayView::from_shape(self.shape(), self.as_slice()?).unwrap())
}
@@ -126,7 +126,7 @@ pub trait Array {
/// Returns an error if the requested type does not match the array's data type.
fn as_view_mut<T: ArrayElement>(
&mut self
- ) -> Result<ArrayViewMut<T, IxDyn>, ArrayConversionError> {
+ ) -> Result<ArrayViewMut<'_, T, IxDyn>, ArrayConversionError> {
Ok(ArrayViewMut::from_shape(
self.shape().to_owned(),
self.as_slice_mut()?,
diff --git a/crates/uzu/src/backends/metal/graph/linear.rs b/crates/uzu/src/backends/metal/graph/linear.rs
index 8255f86ec..f2259cba2 100644
--- a/crates/uzu/src/backends/metal/graph/linear.rs
+++ b/crates/uzu/src/backends/metal/graph/linear.rs
@@ -37,7 +37,12 @@ fn quantized_weights_subgraph<const N: usize>(
parameter_tree: &ParameterTree<Rc<MTLContext>>,
) -> Result<Retained<Tensor>, GraphConstructionError> {
if config.weight_quantization_mode != QuantizationMode::UInt4 {
- unimplemented!("8-bit quantization is not yet implemented.");
+ return Err(GraphConstructionError::IncompatibleDataTypes {
+ node_path: parameter_tree.path_prefix().map(str::to_string),
+ node_name: "weights".to_string(),
+ expected: DataType::U4,
+ actual: DataType::U8,
+ });
}
let output_dim_sum: usize = output_dims.iter().sum();
diff --git a/crates/uzu/src/parameters/loader.rs b/crates/uzu/src/parameters/loader.rs
index 9a320ea3a..c7eb51dff 100644
--- a/crates/uzu/src/parameters/loader.rs
+++ b/crates/uzu/src/parameters/loader.rs
@@ -87,7 +87,7 @@ where
})
}
- pub fn keys(&self) -> Keys<String, ParameterMetadata> {
+ pub fn keys(&self) -> Keys<'_, String, ParameterMetadata> {
self.index.keys()
}