diff --git a/wonnx/src/gpu.rs b/wonnx/src/gpu.rs index c6dc4307..7914ff05 100644 --- a/wonnx/src/gpu.rs +++ b/wonnx/src/gpu.rs @@ -39,7 +39,7 @@ pub struct GpuModel { /// An operation that is performed on the GPU as part of inference enum GpuStep { /// A statically, pre-filled buffer containing tensor data - Initializer(Arc), + Initializer(), /// A buffer containing tensor data that is obtained from inference input Input(String, Arc), @@ -582,7 +582,7 @@ impl GpuModel { ), buffer: tensor_buffer.clone(), }); - GpuStep::Initializer(tensor_buffer) + GpuStep::Initializer() } // For inputs we create an empty buffer that can be used at inference time to supply input data NodeDefinition::Input(input_def) => { @@ -711,9 +711,8 @@ impl TensorProtoExtra for TensorProto { let ints: Vec = self .get_raw_data() .iter() - .map(|x| (*x).try_into()) - .collect::, _>>() - .map_err(|_e| GpuError::OutOfBoundsError)?; + .map(|x| (*x as i32)) + .collect::>(); let raw_data = bytemuck::cast_slice(&ints); buffer_with_bytes(device, readable, self.get_name(), raw_data) } @@ -935,7 +934,7 @@ impl GpuStep { inputs: &HashMap, ) -> Result<(), GpuError> { match self { - GpuStep::None | GpuStep::Forward(_) | GpuStep::Initializer(_) => { + GpuStep::None | GpuStep::Forward(_) | GpuStep::Initializer() => { // Buffer already filled, no need to encode anything at this point. Ok(()) } diff --git a/wonnx/src/optimizer.rs b/wonnx/src/optimizer.rs index 3722dcab..7f270762 100644 --- a/wonnx/src/optimizer.rs +++ b/wonnx/src/optimizer.rs @@ -174,7 +174,7 @@ impl<'model> Optimizer<'model> { }; assert_eq!(op_def.proto.get_op_type(), "Constant"); let proto = &op_def.proto; - let output_name = proto.output.get(0).unwrap().to_owned(); + let output_name = proto.output.first().unwrap().to_owned(); let mut tp: TensorProto = if let Ok(values) = proto.get_attribute_value::>("value_floats", None) { @@ -249,7 +249,7 @@ impl<'model> Optimizer<'model> { // Create an output node so we can perform inference for this node if let NodeDefinition::Operator(op_def) = node.definition() { - let output_name = op_def.proto.output.get(0).unwrap().to_owned(); + let output_name = op_def.proto.output.first().unwrap().to_owned(); let out_node = Arc::new(Node { definition: NodeDefinition::Outputs {