Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
elidupree opened this issue Dec 30, 2022 · 1 comment · May be fixed by #189
Open

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

elidupree opened this issue Dec 30, 2022 · 1 comment · May be fixed by #189
Labels
bug Something doesn't quite look right

Comments

@elidupree
Copy link

I'm a beginner to Juice who is still trying to figure out basic usage, and not finding the book or juice-examples very revelatory. To try to figure things out by experiment, I wrote this (presumably invalid) code:

let backend = Rc::new(juice::util::native_backend());
let linear_1: LayerConfig = LayerConfig::new("linear1", LinearConfig { output_size: 30 });
let mut linear_network_with_one_layer = Layer::from_config(backend, &linear_1);
let input = SharedTensor::<f32>::new(&[1, 1, 50]);
let input_lock = Arc::new(RwLock::new(input));
linear_network_with_one_layer.forward(&[input_lock]);

I was expecting to get an error message like "Error: expected input of size $foo but got input of size $bar". Instead, I got this panic message, which gives me very little help in figuring out what the error is.

As a beginner to Juice, I'm not certain whether this qualifies as a "bug in Juice", but the API docs do not suggest that Layer::forward is supposed to be able to panic.

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/juice-0.3.0/src/layer.rs:535:34
stack backtrace:
   0: rust_begin_unwind
             at /rustc/b7bc90fea3b441234a84b49fdafeb75815eebbab/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/b7bc90fea3b441234a84b49fdafeb75815eebbab/library/core/src/panicking.rs:65:14
   2: core::panicking::panic_bounds_check
             at /rustc/b7bc90fea3b441234a84b49fdafeb75815eebbab/library/core/src/panicking.rs:150:5
   3: <usize as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/b7bc90fea3b441234a84b49fdafeb75815eebbab/library/core/src/slice/index.rs:259:10
   4: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/b7bc90fea3b441234a84b49fdafeb75815eebbab/library/core/src/slice/index.rs:18:9
   5: <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
             at /rustc/b7bc90fea3b441234a84b49fdafeb75815eebbab/library/alloc/src/vec/mod.rs:2736:9
   6: juice::layer::Layer<B>::forward
             at /n/HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/juice-0.3.0/src/layer.rs:535:34
@elidupree elidupree added the bug Something doesn't quite look right label Dec 30, 2022
@drahnr
Copy link
Member

drahnr commented Jan 7, 2023

That definitely is to be considered a bug.

@opfromthestart opfromthestart linked a pull request Jan 31, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something doesn't quite look right
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants