Skip to content

Some better error messages#189

Open
opfromthestart wants to merge 5 commits intofff-rs:masterfrom
opfromthestart:better-error
Open

Some better error messages#189
opfromthestart wants to merge 5 commits intofff-rs:masterfrom
opfromthestart:better-error

Conversation

@opfromthestart
Copy link
Contributor

@opfromthestart opfromthestart commented Jan 31, 2023

What does this PR accomplish?

Makes error messages more readable

  • 🩹 Bug Fix
  • 🦚 Feature
  • 📙 Documentation

Closes #182 .

Changes proposed by this PR:

This replaces some operations that can fail with better error messages

Notes to reviewer:

Unsure of how to test this per se, since it is based on errors.
I don't know all the places it could go wrong, so I need help with identification.

📜 Checklist

  • Add explicit bounds checks when needed
  • Add help messages for common errors
  • Test coverage is excellent
  • All unit tests pass
  • The juice-examples run just fine
  • Documentation is thorough, extensive and explicit

"Input Shape Mismatch\nExpected {:?}\nActual {:?}",
reshaped_shape, old_shape
);
if reshaped_shape[1..] == old_shape[1..] {
Copy link
Member

Choose a reason for hiding this comment

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

I think it'd make more sense to add an assert per dimension, and just fail with the first.

for dim in 0..5 {
     let old = old_shape[dim];
     let reshaped = reshaped__shape[dim];
     assert_eq!(old, reshpaed, "Dimension {dim} mismatches {old} != {reshaped}"); 
}
unreachable!("If the total size is not equal, one dimension mismatch must exist. qed");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did it this way to catch some errors with mismatched batch sizes to make it a bit more clear.

Copy link
Member

Choose a reason for hiding this comment

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

I think it should always show the full dimensions as well. That way it stays clear where it could originate from your code. These errors can arise from rather deep inside the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe that my recent commit should have done this.

for layer in &self.layers {
if layer.borrow().input_blob_names.len() < input_data.len() {
panic!("Layer {} expected {} input(s) but got {}.", layer.borrow().name, layer.borrow().input_blob_names.len(), input_data.len());
}
Copy link
Member

Choose a reason for hiding this comment

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

👍

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.

Unhelpful panic message on (presumably?) invalid inputs to forward

2 participants