Skip to content

Conversation

@Mohit0928
Copy link
Contributor

No description provided.

@Mohit0928 Mohit0928 changed the base branch from master to wit-files-v2 June 16, 2022 09:55
fn run(&self, inputs: Vec<Tensor>) -> Result<Vec<Tensor>, RunError> {
let tensor = Tensor::get_named(&inputs, "confidences")?;

let count = parse::required_arg(&vec![Argument{ name: "count".to_string(), value: self.count.to_string() }], "count").unwrap();
Copy link
Contributor

@Michael-F-Bryan Michael-F-Bryan Jun 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be deleted because we get count when first using the TryFrom<Vec<Argument>> to construct our MostConfidentIndices object.

);

Ok(())
Ok(vec![Tensor::new_1d("indices", &indices.to_vec())])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .to_vec() here is redundant. The indices variable has type Vec<u32>, and doing &indices will pass a &[u32] to the Tensor::new_1d() function1.

Suggested change
Ok(vec![Tensor::new_1d("indices", &indices.to_vec())])
Ok(vec![Tensor::new_1d("indices", &indices)])

Footnotes

  1. Well technically &indices gives us a &Vec<u32>, but Vec<u32> implements Deref where the Target type is [u32], so the compiler can automatically coerce &Vec<u32> to &[u32] because of "deref coersions".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants