Segmentation fault with GetTensorMutableData
nbigaouette opened this issue · 1 comments
nbigaouette commented
Using GetTensorMutableData
to read back resulting tensor segfaults:
❯ cargo run --example c_api_sample
Finished dev [unoptimized + debuginfo] target(s) in 0.08s
Running `target/debug/examples/c_api_sample`
g_ort: 0x10a60e5d8
Using Onnxruntime C API
2020-08-04 10:11:10.866050 [I:onnxruntime:, inference_session.cc:174 ConstructorCommon] Creating and using per session threadpools since use_per_session_threads_ is true
2020-08-04 10:11:10.874242 [I:onnxruntime:, inference_session.cc:830 Initialize] Initializing session.
2020-08-04 10:11:10.874281 [I:onnxruntime:, inference_session.cc:848 Initialize] Adding default CPU execution provider.
2020-08-04 10:11:10.874334 [I:onnxruntime:test, bfc_arena.cc:15 BFCArena] Creating BFCArena for Cpu
2020-08-04 10:11:10.874356 [V:onnxruntime:test, bfc_arena.cc:32 BFCArena] Creating 21 bins of max chunk size 256 to 268435456
2020-08-04 10:11:10.881963 [I:onnxruntime:, reshape_fusion.cc:37 ApplyImpl] Total fused reshape node count: 0
2020-08-04 10:11:10.886945 [I:onnxruntime:, reshape_fusion.cc:37 ApplyImpl] Total fused reshape node count: 0
2020-08-04 10:11:10.888130 [I:onnxruntime:, reshape_fusion.cc:37 ApplyImpl] Total fused reshape node count: 0
2020-08-04 10:11:10.889268 [V:onnxruntime:, inference_session.cc:671 TransformGraph] Node placements
2020-08-04 10:11:10.889318 [V:onnxruntime:, inference_session.cc:673 TransformGraph] All nodes have been placed on [CPUExecutionProvider].
2020-08-04 10:11:10.889525 [I:onnxruntime:, session_state.cc:25 SetGraph] SaveMLValueNameIndexMapping
2020-08-04 10:11:10.889922 [I:onnxruntime:, session_state.cc:70 SetGraph] Done saving OrtValue mappings.
2020-08-04 10:11:10.893268 [I:onnxruntime:, session_state_initializer.cc:178 SaveInitializedTensors] Saving initialized tensors.
2020-08-04 10:11:10.896629 [I:onnxruntime:, session_state_initializer.cc:223 SaveInitializedTensors] Done saving initialized tensors
2020-08-04 10:11:10.899166 [I:onnxruntime:, inference_session.cc:919 Initialize] Session successfully initialized.
Number of inputs = 1
Input 0 : name=data_0
Input 0 : type=1
Input 0 : num_dims=4
Input 0 : dim 0=1
Input 0 : dim 1=3
Input 0 : dim 2=224
Input 0 : dim 3=224
input_node_dims: [1, 3, 224, 224]
input_node_names[0]: "data_0"
output_node_names[0]: "softmaxout_1"
2020-08-04 10:11:10.908541 [I:onnxruntime:, sequential_executor.cc:145 Execute] Begin execution
2020-08-04 10:11:10.908632 [I:onnxruntime:test, bfc_arena.cc:259 AllocateRawInternal] Extending BFCArena for Cpu. bin_num:13 rounded_bytes:3154176
2020-08-04 10:11:10.908676 [I:onnxruntime:test, bfc_arena.cc:143 Extend] Extended allocation by 4194304 bytes.
2020-08-04 10:11:10.908690 [I:onnxruntime:test, bfc_arena.cc:147 Extend] Total allocated bytes: 9137152
2020-08-04 10:11:10.908705 [I:onnxruntime:test, bfc_arena.cc:150 Extend] Allocated memory at 0x7fa051c00000 to 0x7fa052000000
2020-08-04 10:11:10.908789 [I:onnxruntime:test, bfc_arena.cc:259 AllocateRawInternal] Extending BFCArena for Cpu. bin_num:8 rounded_bytes:65536
2020-08-04 10:11:10.908809 [I:onnxruntime:test, bfc_arena.cc:143 Extend] Extended allocation by 4194304 bytes.
2020-08-04 10:11:10.908822 [I:onnxruntime:test, bfc_arena.cc:147 Extend] Total allocated bytes: 13331456
2020-08-04 10:11:10.908834 [I:onnxruntime:test, bfc_arena.cc:150 Extend] Allocated memory at 0x7fa0554b7000 to 0x7fa0558b7000
thread 'main' panicked at 'assertion failed: (unsafe { *floatarr } - 0.000045).abs() < 1e-6', onnxruntime-sys/examples/c_api_sample.rs:413:5
nbigaouette commented
Eurg... The problem was a bad conversion on my side. The C example used float
, which in Rust is f32
, not f64
. Dummy mistake...