Skip to content

Commit

Permalink
chore: lints
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelspark committed Mar 31, 2024
1 parent df34358 commit 63ce338
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions wonnx/src/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Buffer>),
Initializer(),

/// A buffer containing tensor data that is obtained from inference input
Input(String, Arc<Buffer>),
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -711,9 +711,8 @@ impl TensorProtoExtra for TensorProto {
let ints: Vec<i32> = self
.get_raw_data()
.iter()
.map(|x| (*x).try_into())
.collect::<Result<Vec<i32>, _>>()
.map_err(|_e| GpuError::OutOfBoundsError)?;
.map(|x| (*x as i32))
.collect::<Vec<i32>>();
let raw_data = bytemuck::cast_slice(&ints);
buffer_with_bytes(device, readable, self.get_name(), raw_data)
}
Expand Down Expand Up @@ -935,7 +934,7 @@ impl GpuStep {
inputs: &HashMap<String, InputTensor>,
) -> 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(())
}
Expand Down
4 changes: 2 additions & 2 deletions wonnx/src/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<f32>>("value_floats", None) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 63ce338

Please sign in to comment.