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

rust panic with CPU backend in xor example #71

Open
MellKam opened this issue Jan 1, 2025 · 1 comment
Open

rust panic with CPU backend in xor example #71

MellKam opened this issue Jan 1, 2025 · 1 comment

Comments

@MellKam
Copy link

MellKam commented Jan 1, 2025

Hi! I just copied the xor example from the readme to test this library, but I couldn't run it. I also needed to add import for tensor1D, as it was not defined in the example.

> deno run -A ./src/xor.ts
Downloading https://github.com/denosaurs/netsaur/releases/download/0.4.2/libnetsaur.so
CPU Backend Initialized
thread '<unnamed>' panicked at crates/core/src/cpu/layers/dense.rs:65:59:
called `Result::unwrap()` on an `Err` value: ShapeError/IncompatibleShape: incompatible shapes
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at core/src/panicking.rs:221:5:
panic in a function that cannot unwind
stack backtrace:
   0:     0x7fd0c4375a3a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h7265b42392dc0061
   1:     0x7fd0c43965d3 - core::fmt::write::h2ec550f80b7defd0
   2:     0x7fd0c43733a3 - std::io::Write::write_fmt::h36bfe942596e7c0c
   3:     0x7fd0c4375882 - std::sys::backtrace::BacktraceLock::print::h91696b5f38231729
   4:     0x7fd0c43767a7 - std::panicking::default_hook::{{closure}}::h9bab7dd14eb60554
   5:     0x7fd0c43765d6 - std::panicking::default_hook::hf96ee8bd37f2a078
   6:     0x7fd0c4376d97 - std::panicking::rust_panic_with_hook::h78f8bdf8cf52544b
   7:     0x7fd0c4376bf6 - std::panicking::begin_panic_handler::{{closure}}::hefdc3b651bce153f
   8:     0x7fd0c4375f19 - std::sys::backtrace::__rust_end_short_backtrace::ha5a68a90f678ccff
   9:     0x7fd0c43768bc - rust_begin_unwind
  10:     0x7fd0c4394a9d - core::panicking::panic_nounwind_fmt::h2fd0917b1a8df192
  11:     0x7fd0c4394b32 - core::panicking::panic_nounwind::h545911dcc38f2643
  12:     0x7fd0c4394bf5 - core::panicking::panic_cannot_unwind::h3f615319d02b7fb8
  13:     0x7fd0c4318af4 - ffi_backend_predict
  14:     0x564290908052 - ffi_call_unix64
  15:     0x564293b813fa - ffi_call_int.llvm.8777122752065301370
  16:     0x564293b81171 - ffi_call
  17:     0x564293b4fe9c - <extern "C" fn(A0) .> R as v8::support::CFnFrom<F>>::mapping::c_fn::h8ff842577632e711
  18:     0x564231d8f1c6 - <unknown>
thread caused non-unwinding panic. aborting.
Aborted (core dumped)
> deno --version
deno 2.1.4 (stable, release, x86_64-unknown-linux-gnu)
v8 13.0.245.12-rusty
typescript 5.6.2

Platform: WSL2

@retraigo
Copy link
Collaborator

I think we forgot to update the example in the README. predict() will panic if you give it a tensor1D. Working examples can be found in the examples directory (like xor_cpu.ts).

Instead of tensor1D([0, 0]) it should be tensor2D([[0, 0]]) and so on.

Also it'd be helpful if this issue is left open so that we can keep the README change in our todo.

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

No branches or pull requests

2 participants