-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_onnx_crash.cpp
More file actions
56 lines (43 loc) · 2.23 KB
/
debug_onnx_crash.cpp
File metadata and controls
56 lines (43 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//==============================================================================
// debug_onnx_crash.cpp
// Minimal test to debug ONNX Runtime crash
//==============================================================================
#include <iostream>
#include <onnxruntime_cxx_api.h>
int main()
{
std::cout << "=== ONNX Runtime Crash Debugging ===" << std::endl;
try {
std::cout << "1. Creating environment with different log levels..." << std::endl;
// Try with more verbose logging
Ort::Env env(ORT_LOGGING_LEVEL_VERBOSE, "debug_test");
std::cout << " ✓ Environment created" << std::endl;
std::cout << "2. Creating session options with careful configuration..." << std::endl;
Ort::SessionOptions session_options;
// Add some safety options
session_options.SetIntraOpNumThreads(1);
session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_DISABLE_ALL);
std::cout << " ✓ Session options configured" << std::endl;
std::cout << "3. Attempting to load smaller model first..." << std::endl;
std::string modelPath = "models/midi-model/onnx/model_token.onnx";
// Use a try-catch specifically for the session creation
std::cout << " Creating session for: " << modelPath << std::endl;
Ort::Session session(env, modelPath.c_str(), session_options);
std::cout << " ✓ SUCCESS! Model loaded without crash" << std::endl;
// If we get here, try to get basic info
size_t numInputs = session.GetInputCount();
std::cout << " Model has " << numInputs << " inputs" << std::endl;
} catch (const Ort::Exception& e) {
std::cout << " ❌ ONNX Exception: " << e.what() << std::endl;
std::cout << " Error code: " << e.GetOrtErrorCode() << std::endl;
return 1;
} catch (const std::exception& e) {
std::cout << " ❌ Standard Exception: " << e.what() << std::endl;
return 1;
} catch (...) {
std::cout << " ❌ Unknown exception caught" << std::endl;
return 1;
}
std::cout << "🎉 Test completed successfully!" << std::endl;
return 0;
}