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

Copying Scalars from Torch to Rust? #853

Open
Jark5455 opened this issue Mar 4, 2024 · 1 comment
Open

Copying Scalars from Torch to Rust? #853

Jark5455 opened this issue Mar 4, 2024 · 1 comment

Comments

@Jark5455
Copy link
Contributor

Jark5455 commented Mar 4, 2024

Currently, when I try to copy a scalar value from a 0 dim tensor with double_value(&[0]), it returns the following error

called `Result::unwrap()` on an `Err` value: Torch("select() cannot be applied to a 0-dim tensor.\nException raised from select_symint at /build/python-pytorch/src/pytorch-cuda/aten/src/ATen/native/TensorShape.cpp:1827 (most recent call first):\nframe #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0xa2 (0x73af2cd9c8a2 in /usr/lib/libc10.so)\nframe #1: <unknown function> + 0x7a9854 (0x73af21da9854 in /usr/lib/libtorch_cpu.so)\nframe #2: <unknown function> + 0x23130c5 (0x73af239130c5 in /usr/lib/libtorch_cpu.so)\nframe #3: at::_ops::select_int::redispatch(c10::DispatchKeySet, at::Tensor const&, long, c10::SymInt) + 0xc5 (0x73af234e5e75 in /usr/lib/libtorch_cpu.so)\nframe #4: <unknown function> + 0x438bc40 (0x73af2598bc40 in /usr/lib/libtorch_cpu.so)\nframe #5: <unknown function> + 0x438bf6c (0x73af2598bf6c in /usr/lib/libtorch_cpu.so)\nframe #6: at::_ops::select_int::redispatch(c10::DispatchKeySet, at::Tensor const&, long, c10::SymInt) + 0xc5 (0x73af234e5e75 in /usr/lib/libtorch_cpu.so)\nframe #7: <unknown function> + 0x3d36167 (0x73af25336167 in /usr/lib/libtorch_cpu.so)\nframe #8: <unknown function> + 0x3d3688c (0x73af2533688c in /usr/lib/libtorch_cpu.so)\nframe #9: at::_ops::select_int::call(at::Tensor const&, long, c10::SymInt) + 0x1b1 (0x73af235535e1 in /usr/lib/libtorch_cpu.so)\nframe #10: at::Tensor::select(long, long) const + 0x53 (0x5fdc7c88649d in ./Milkshake)\nframe #11: <unknown function> + 0x1e11bd (0x5fdc7c8861bd in ./Milkshake)\nframe #12: <unknown function> + 0x1ef078 (0x5fdc7c894078 in ./Milkshake)\nframe #13: <unknown function> + 0x1e8e19 (0x5fdc7c88de19 in ./Milkshake)\nframe #14: <unknown function> + 0x1b099f (0x5fdc7c85599f in ./Milkshake)\nframe #15: <unknown function> + 0x1b0a75 (0x5fdc7c855a75 in ./Milkshake)\nframe #16: <unknown function> + 0x388c5 (0x5fdc7c6dd8c5 in ./Milkshake)\nframe #17: <unknown function> + 0x4a4f9 (0x5fdc7c6ef4f9 in ./Milkshake)\nframe #18: <unknown function> + 0x5d985 (0x5fdc7c702985 in ./Milkshake)\nframe #19: <unknown function> + 0x5f771 (0x5fdc7c704771 in ./Milkshake)\nframe #20: <unknown function> + 0x4f19b (0x5fdc7c6f419b in ./Milkshake)\nframe #21: <unknown function> + 0x367de (0x5fdc7c6db7de in ./Milkshake)\nframe #22: <unknown function> + 0x452a1 (0x5fdc7c6ea2a1 in ./Milkshake)\nframe #23: <unknown function> + 0x44b961 (0x5fdc7caf0961 in ./Milkshake)\nframe #24: <unknown function> + 0x4527a (0x5fdc7c6ea27a in ./Milkshake)\nframe #25: <unknown function> + 0x60e5e (0x5fdc7c705e5e in ./Milkshake)\nframe #26: <unknown function> + 0x25cd0 (0x73af21357cd0 in /usr/lib/libc.so.6)\nframe #27: __libc_start_main + 0x8a (0x73af21357d8a in /usr/lib/libc.so.6)\nframe #28: <unknown function> + 0x35eb5 (0x5fdc7c6daeb5 in ./Milkshake)\n")

What is the intended way to copy the values of tensors?

@iago-lito
Copy link

Hi, if your tensor has no dims, maybe .double_value(&[]); ?

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