raskr / rust-autograd

Tensors and differentiable operations (like TensorFlow) in Rust
MIT License
484 stars 36 forks source link

Index out of bound in DivOp when dividing 2 scalars #50

Closed yshui closed 2 years ago

yshui commented 3 years ago

stacktrace:

   0: rust_begin_unwind
             at /rustc/08095fc1f875c89e507f17cf6c6a780c8ffa4c01/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/08095fc1f875c89e507f17cf6c6a780c8ffa4c01/library/std/src/panicking.rs:457:5
   2: ndarray::arraytraits::<impl core::ops::index::Index<I> for ndarray::ArrayBase<S,D>>::index
             at /home/shui/.cargo/registry/src/github.com-1ecc6299db9ec823/ndarray-0.12.1/src/arraytraits.rs:56:9
   3: <autograd::ops::binary_ops::DivOp as autograd::op::Op<T>>::compute
             at /home/shui/.cargo/registry/src/github.com-1ecc6299db9ec823/autograd-1.1.0/src/ops/binary_ops.rs:247:27
   4: autograd::runtime::<impl autograd::graph::Graph<F>>::eval::{{closure}}
             at /home/shui/.cargo/registry/src/github.com-1ecc6299db9ec823/autograd-1.1.0/src/runtime.rs:392:25
   5: core::result::Result<T,E>::and_then
             at /rustc/08095fc1f875c89e507f17cf6c6a780c8ffa4c01/library/core/src/result.rs:948:22
   6: autograd::runtime::<impl autograd::graph::Graph<F>>::eval
             at /home/shui/.cargo/registry/src/github.com-1ecc6299db9ec823/autograd-1.1.0/src/runtime.rs:390:47
...

Looks like x1 has shape of [1], i.e. 1-dimension, but the index is 0-dimension.

raskr commented 2 years ago

@yshui do you have repro code ?

yshui commented 2 years ago

I can't reproduce it anymore