Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
2e4d205
progress
CharlieL7 Jan 13, 2026
bb622af
dd
CharlieL7 Feb 18, 2026
277ff30
Merge branch 'develop' of github.com:ROCm/AMDMIGraphX into ins_debug_…
CharlieL7 Feb 18, 2026
432ed83
Add onnx_parser and module changes
CharlieL7 Feb 18, 2026
c2381cb
Change to use a set of debug_symbols when inserting ins
CharlieL7 Feb 18, 2026
b00e7e2
Incomplete first parse design
CharlieL7 Feb 19, 2026
1517438
Version 2 using scoped debug symbols in module
CharlieL7 Feb 19, 2026
b8e1cdb
Cleanup
CharlieL7 Feb 19, 2026
ec7487e
cleanup 2
CharlieL7 Feb 19, 2026
f499489
Formatting
CharlieL7 Feb 19, 2026
8324d9b
Add debug propagate with matcher context
CharlieL7 Feb 20, 2026
c9f567f
formatting
CharlieL7 Feb 20, 2026
e66c848
tests and fixup
CharlieL7 Feb 20, 2026
42eaac8
Merge branch 'develop' of github.com:ROCm/AMDMIGraphX into ins_debug_…
CharlieL7 Feb 20, 2026
a769c11
Add docs changes
CharlieL7 Feb 20, 2026
7321509
Have gather_replace_debug_symbols traverse empty
CharlieL7 Feb 20, 2026
2794a66
Copilot suggestions
CharlieL7 Feb 20, 2026
69c787a
more copilot
CharlieL7 Feb 20, 2026
d90382c
Update CHANGELOG.md
CharlieL7 Feb 20, 2026
107a7e7
Update src/module.cpp
CharlieL7 Feb 20, 2026
f9bb2c8
Revert matcher.hpp
CharlieL7 Feb 23, 2026
3d3bc42
Revert env_var doc
CharlieL7 Feb 23, 2026
66b0a2f
Review progress
CharlieL7 Feb 23, 2026
3cff180
Merge branch 'ins_debug_symbols' of github.com:ROCm/AMDMIGraphX into …
CharlieL7 Feb 23, 2026
b3c8a1c
Module tracking number of instructions with debug_symbols
CharlieL7 Feb 24, 2026
5830120
Cleanup
CharlieL7 Feb 24, 2026
f3e9709
Merge branch 'develop' of github.com:ROCm/AMDMIGraphX into ins_debug_…
CharlieL7 Feb 24, 2026
593fc75
Revert simplify_algebra
CharlieL7 Feb 24, 2026
fbdd1e8
Fix implementation and tests
CharlieL7 Mar 3, 2026
4e1cee9
splice fix and add gemm->add->add test
CharlieL7 Mar 4, 2026
dadc312
Refine the set difference algo and tests
CharlieL7 Mar 4, 2026
9a32dc4
Formatting
CharlieL7 Mar 4, 2026
7476ccf
Merge branch 'develop' of github.com:ROCm/AMDMIGraphX into ins_debug_…
CharlieL7 Mar 4, 2026
bd1997a
Formatting
CharlieL7 Mar 4, 2026
573ee7f
Update program serialization and fix EXPECT dangling ref
CharlieL7 Mar 4, 2026
8e8993d
Formatting
CharlieL7 Mar 4, 2026
0336f6d
Undo serialization changes for another PR
CharlieL7 Mar 4, 2026
2788196
Add more tests directly calling module::replace_ins
CharlieL7 Mar 4, 2026
0c7506b
Add onnx parse tests
CharlieL7 Mar 4, 2026
95a5d9e
Tidy fixes
CharlieL7 Mar 5, 2026
80f3e47
Licensing
CharlieL7 Mar 5, 2026
3f6e1a7
formatting
CharlieL7 Mar 5, 2026
c148ea6
Merge branch 'develop' of github.com:ROCm/AMDMIGraphX into ins_debug_…
CharlieL7 Mar 5, 2026
e2ea3ae
parser get_added_instructions only if used
CharlieL7 Mar 5, 2026
6c0f142
Fixes
CharlieL7 Mar 5, 2026
ac24118
more copilot fixes
CharlieL7 Mar 5, 2026
821aab6
Cleanup env
CharlieL7 Mar 6, 2026
3ba71ec
Add notify
CharlieL7 Mar 6, 2026
cfe37d6
Module const func
CharlieL7 Mar 6, 2026
a5c6706
Update gitignore
CharlieL7 Mar 6, 2026
cb0a3e8
formatting again
CharlieL7 Mar 6, 2026
2a0365b
join_strings to use const ref instead
CharlieL7 Mar 9, 2026
19f6165
Comment formatting
CharlieL7 Mar 9, 2026
7a4b3f4
Remove redunant test
CharlieL7 Mar 9, 2026
287b79b
More tests
CharlieL7 Mar 9, 2026
3f1ec9d
Add tests for module::remove_instruction changes
CharlieL7 Mar 10, 2026
508f29b
Merge branch 'develop' of github.com:ROCm/AMDMIGraphX into ins_debug_…
CharlieL7 Mar 10, 2026
162c811
Add debug symbols to MXR
CharlieL7 Mar 10, 2026
acffe7e
Tidy fix
CharlieL7 Mar 10, 2026
5e459d8
Merge branch 'ins_debug_symbols' of github.com:ROCm/AMDMIGraphX into …
CharlieL7 Mar 10, 2026
3e014fb
Revert stringutils change
CharlieL7 Mar 10, 2026
3393535
Revert properly
CharlieL7 Mar 10, 2026
4117546
Merge branch 'ins_debug_symbols' of github.com:ROCm/AMDMIGraphX into …
CharlieL7 Mar 10, 2026
bb471fb
Prototype version with commented out new reaches code
CharlieL7 Mar 11, 2026
4a1469b
Optimize the DFS calls
CharlieL7 Mar 12, 2026
abfa3d2
Commented out code cleanup
CharlieL7 Mar 12, 2026
0abea08
Fix serialization
CharlieL7 Mar 12, 2026
6b3cce7
Formatting
CharlieL7 Mar 12, 2026
5162ceb
Tidy fix
CharlieL7 Mar 12, 2026
a2a4bed
revert test.hpp changes
CharlieL7 Mar 16, 2026
3805cab
Replace instruction refactor
CharlieL7 Mar 18, 2026
b5e6816
revert instruction::reaches changes
CharlieL7 Mar 18, 2026
6671be0
Edit debug symbols print
CharlieL7 Mar 18, 2026
4b7c5ac
Revert op builder changes
CharlieL7 Mar 18, 2026
caa2a98
Edit .build*/ to .build/
CharlieL7 Mar 18, 2026
4fb59f0
Keep only build* fix
CharlieL7 Mar 23, 2026
b95aff8
Fix op_builders error
CharlieL7 Mar 23, 2026
8b6053e
Cleanup
CharlieL7 Mar 23, 2026
dfd5f69
Revert gitignore
CharlieL7 Mar 23, 2026
716033c
add tests and tidy
CharlieL7 Mar 23, 2026
1e237d5
Comment update
CharlieL7 Mar 24, 2026
bfa594f
formatting
CharlieL7 Mar 24, 2026
60143f7
copilot fixes
CharlieL7 Mar 24, 2026
7c266dd
Merge branch 'develop' of github.com:ROCm/AMDMIGraphX into ins_debug_…
CharlieL7 Mar 24, 2026
6a3ae3c
copilot review updates
CharlieL7 Mar 24, 2026
17d3f1d
licensing
CharlieL7 Mar 24, 2026
56ce83a
Formatting
CharlieL7 Mar 24, 2026
115f111
Fix bug with replace_instruction debug symbols that have no inputs
CharlieL7 Mar 24, 2026
9d8f0cf
Remove print
CharlieL7 Mar 24, 2026
3eea60c
Move and change tests
CharlieL7 Mar 25, 2026
9b2f759
Update API to set onnx_options use_debug_symbols
CharlieL7 Mar 26, 2026
fc3850c
Merge branch 'develop' of github.com:ROCm/AMDMIGraphX into ins_debug_…
CharlieL7 Mar 26, 2026
17d4595
Review comments
CharlieL7 Mar 27, 2026
e5b2009
Formatting
CharlieL7 Mar 27, 2026
e710cf6
License
CharlieL7 Mar 27, 2026
ce9d36c
Add tidy const to header
CharlieL7 Mar 30, 2026
a9519a5
Add debug symbols interface to api
CharlieL7 Apr 1, 2026
14cb668
Revert "Add debug symbols interface to api"
CharlieL7 Apr 1, 2026
f0f5b78
clean up const-ness
CharlieL7 Apr 1, 2026
bd39c88
Merge branch 'develop' of github.com:ROCm/AMDMIGraphX into ins_debug_…
CharlieL7 Apr 7, 2026
51b4cfe
Formatting
CharlieL7 Apr 7, 2026
2dca4f7
Remove constness
CharlieL7 Apr 7, 2026
f5acdc1
Tidy no lint stringutils
CharlieL7 Apr 7, 2026
904d37b
License date
CharlieL7 Apr 7, 2026
48b9f78
Formatting agin
CharlieL7 Apr 7, 2026
748e2bc
Cleanup replace_instruction code
CharlieL7 Apr 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Full documentation for MIGraphX is available at
* Added Cubic resize jit kernel (#4652).
* Added JIT compiler for `fill` operation (#4666).
* Added JIT compiler for `multinomial` operation (#4721).
* Added debug symbols for MIGraphX instructions such that parsed and compiled instructions can be tracked back to their ONNX origin node (#4626)

### Changed

Expand Down
16 changes: 16 additions & 0 deletions src/api/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ static void set_limit_loop_iterations(onnx_options& options, int64_t value)
options.limit_max_iterations = value;
}

static void set_use_debug_symbols(onnx_options& options, bool value)
{
options.use_debug_symbols = value;
}

static void set_nhwc(tf_options& options, bool is_nhwc) { options.is_nhwc = is_nhwc; }

static void set_default_dim_value(tf_options& options, size_t value) { options.batch_size = value; }
Expand Down Expand Up @@ -1991,6 +1996,17 @@ migraphx_onnx_options_set_external_data_path(migraphx_onnx_options_t onnx_option
return api_error_result;
}

extern "C" migraphx_status
migraphx_onnx_options_set_use_debug_symbols(migraphx_onnx_options_t onnx_options, bool value)
{
auto api_error_result = migraphx::try_([&] {
if(onnx_options == nullptr)
MIGRAPHX_THROW(migraphx_status_bad_param, "Bad parameter onnx_options: Null pointer");
migraphx::set_use_debug_symbols((onnx_options->object), (value));
});
return api_error_result;
}

extern "C" migraphx_status migraphx_file_options_destroy(migraphx_file_options_t file_options)
{
auto api_error_result = migraphx::try_([&] { destroy((file_options)); });
Expand Down
5 changes: 4 additions & 1 deletion src/api/include/migraphx/migraphx.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2026 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -535,6 +535,9 @@ MIGRAPHX_C_EXPORT migraphx_status migraphx_onnx_options_set_limit_loop_iteration
MIGRAPHX_C_EXPORT migraphx_status migraphx_onnx_options_set_external_data_path(
migraphx_onnx_options_t onnx_options, const char* external_data_path);

MIGRAPHX_C_EXPORT migraphx_status
migraphx_onnx_options_set_use_debug_symbols(migraphx_onnx_options_t onnx_options, bool value);

MIGRAPHX_C_EXPORT migraphx_status
migraphx_file_options_destroy(migraphx_file_options_t file_options);

Expand Down
8 changes: 7 additions & 1 deletion src/api/include/migraphx/migraphx.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2026 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -1366,6 +1366,12 @@ struct onnx_options : MIGRAPHX_HANDLE_BASE(onnx_options)
this->get_handle_ptr(),
external_data_path.c_str());
}

/// Enable debug symbols from ONNX node names
void set_use_debug_symbols(bool value = true)
{
call(&migraphx_onnx_options_set_use_debug_symbols, this->get_handle_ptr(), value);
}
};

/// Parse an onnx file into a migraphx program
Expand Down
7 changes: 6 additions & 1 deletion src/api/migraphx.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2015-2026 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -370,6 +370,11 @@ def onnx_options(h):
api.params(external_data_path='const char*'),
invoke='migraphx::set_external_data_path($@)',
)
h.method(
'set_use_debug_symbols',
api.params(value='bool'),
invoke='migraphx::set_use_debug_symbols($@)',
)


@auto_handle()
Expand Down
7 changes: 7 additions & 0 deletions src/driver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ struct loader
bool replace_literals = false;
bool brief = false;
bool verbose = false;
bool use_debug_symbols = false;
std::string output_type;
std::string output;
std::string default_dyn_dim;
Expand Down Expand Up @@ -223,6 +224,11 @@ struct loader
ap.help("Skip unknown operators when parsing and continue to parse."),
ap.set_value(true));
ap(is_nhwc, {"--nchw"}, ap.help("Treat tensorflow format as nchw"), ap.set_value(false));
ap(use_debug_symbols,
{"--debug-symbols"},
ap.help(
"Parse ONNX node names into MIGX instructions and propagate them as debug symbols."),
ap.set_value(true));
ap(trim, {"--trim", "-t"}, ap.help("Trim instructions from the end"));
ap(trim_size, {"--trim-size", "-s"}, ap.help("Number of instructions in the trim model"));
ap(param_dims,
Expand Down Expand Up @@ -410,6 +416,7 @@ struct loader
}
options.skip_unknown_operators = skip_unknown_operators;
options.print_program_on_error = true;
options.use_debug_symbols = use_debug_symbols;
options.map_input_dims = map_input_dims;
options.map_dyn_input_dims = map_dyn_input_dims;
options.dim_params = map_dim_params;
Expand Down
12 changes: 11 additions & 1 deletion src/include/migraphx/instruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
#include <migraphx/operation.hpp>
#include <migraphx/erase.hpp>
#include <migraphx/config.hpp>
#include <string>
#include <set>
#include <unordered_set>
#include <string>
#include <utility>

namespace migraphx {
Expand Down Expand Up @@ -95,6 +96,14 @@ struct MIGRAPHX_EXPORT instruction
/// Where this instruction is used as an input to another instruction
const std::vector<instruction_ref>& outputs() const;

const std::set<std::string>& get_debug_symbols() const;

/// Avoid using directly because module will not track number of debug symbols
void add_debug_symbols(const std::set<std::string>& symbols);

/// Avoid using directly because module will not track number of debug symbols
void remove_debug_symbols();

MIGRAPHX_EXPORT friend bool operator==(const instruction& x, const instruction& y);

MIGRAPHX_EXPORT friend bool operator!=(const instruction& x, const instruction& y);
Expand Down Expand Up @@ -188,6 +197,7 @@ struct MIGRAPHX_EXPORT instruction
std::vector<instruction_ref> output;
std::vector<instruction_ref> arguments;
std::vector<module_ref> module_args;
std::set<std::string> debug_symbols;
literal lit;
bool normalized = false;
std::size_t target_id = 0;
Expand Down
27 changes: 24 additions & 3 deletions src/include/migraphx/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
#ifndef MIGRAPHX_GUARD_MIGRAPHLIB_MODULE_HPP
#define MIGRAPHX_GUARD_MIGRAPHLIB_MODULE_HPP

#include <list>
#include <unordered_set>
#include <unordered_map>
#include <migraphx/operation.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/builtin.hpp>
Expand All @@ -38,6 +35,10 @@
#include <migraphx/config.hpp>
#include <algorithm>
#include <iostream>
#include <list>
#include <set>
#include <unordered_set>
#include <unordered_map>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
Expand Down Expand Up @@ -81,6 +82,13 @@ struct MIGRAPHX_EXPORT module
bool bypass() const;
void set_bypass(bool b = true);

/// If any instructions in this module have debug symbols
bool has_debug_symbols() const;
/// Merge given symbols with instruction's symbols
void add_debug_symbols(instruction_ref ins, const std::set<std::string>& symbols);
/// Clear all debug symbols from instruction
void remove_debug_symbols(instruction_ref ins);

template <class... Ts, MIGRAPHX_REQUIRES(std::is_same<Ts, instruction_ref>{}...)>
instruction_ref add_instruction(operation op, Ts... args)
{
Expand Down Expand Up @@ -122,6 +130,19 @@ struct MIGRAPHX_EXPORT module

instruction_ref replace_instruction(instruction_ref ins, instruction_ref rep);

struct instruction_replacement
{
instruction_ref ins;
operation op;
std::vector<instruction_ref> args;
std::vector<module_ref> module_args;
};

/// Replaces an array of instructions within the same function to properly handle debug symbols
/// propagation. Returns vector of instruction_ref to replaced instructions.
std::vector<instruction_ref>
batch_replace_instruction(const std::vector<instruction_replacement>& replacers);

instruction_ref remove_instruction(instruction_ref ins);
instruction_ref remove_instructions(instruction_ref first, instruction_ref last);

Expand Down
4 changes: 3 additions & 1 deletion src/include/migraphx/onnx.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2026 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -58,6 +58,8 @@ struct onnx_options
int64_t limit_max_iterations = std::numeric_limits<uint16_t>::max();
/// Use dynamic output for operators when available
bool use_dyn_output = false;
/// Parse in ONNX node names as debug symbols
bool use_debug_symbols = false;
/// Path to use for the external data if it is stored at different location compared to onnx
/// file
std::string external_data_path = "";
Expand Down
7 changes: 5 additions & 2 deletions src/include/migraphx/stringutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ inline bool ends_with(const std::string& value, const std::string& suffix)
else
return std::equal(suffix.rbegin(), suffix.rend(), value.rbegin());
}

// NOLINTBEGIN(performance-unnecessary-value-param)
template <class Strings>
inline std::string join_strings(Strings strings, const std::string& delim)
inline std::string
join_strings(Strings strings,
const std::string& delim)
// NOLINTEND(performance-unnecessary-value-param)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why tidy is complaining here. This function hasnt changed.

{
auto it = strings.begin();
if(it == strings.end())
Expand Down
32 changes: 30 additions & 2 deletions src/instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <migraphx/ranges.hpp>
#include <migraphx/output_iterator.hpp>
#include <migraphx/iterator.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/iterator_for.hpp>
#include <bitset>
#include <queue>
Expand Down Expand Up @@ -189,6 +190,15 @@ const std::vector<module_ref>& instruction::module_inputs() const { return modul

const std::vector<instruction_ref>& instruction::outputs() const { return output; }

const std::set<std::string>& instruction::get_debug_symbols() const { return debug_symbols; }

void instruction::add_debug_symbols(const std::set<std::string>& symbols)
{
debug_symbols.insert(symbols.begin(), symbols.end());
}

void instruction::remove_debug_symbols() { debug_symbols.clear(); }
Comment thread
CharlieL7 marked this conversation as resolved.

bool operator==(const instruction& x, const instruction& y)
{
if(not std::equal(x.arguments.begin(),
Expand Down Expand Up @@ -274,7 +284,7 @@ void instruction::replace(operation o,
std::vector<module_ref> mdl_args)
{
lit = literal{};
op = std::move(o);
op = std::move(o);
replace(r);
replace(std::move(args), std::move(mdl_args));
}
Expand Down Expand Up @@ -442,6 +452,12 @@ void instruction::print(std::ostream& os,
// print tid
if(ins->target_id != 0)
os << ", target_id=" << ins->target_id;

// print debug symbols if they exist
if(not ins->debug_symbols.empty())
{
os << " # " << join_strings(ins->debug_symbols, ", ");
}
}

static void debug_name(std::ostream& os, const instruction& ins)
Expand Down Expand Up @@ -472,7 +488,14 @@ void instruction::debug_print() const
}
if(not this->inputs().empty())
std::cout << ")";
std::cout << " -> " << this->get_shape() << std::endl;
std::cout << " -> " << this->get_shape();
Comment thread
CharlieL7 marked this conversation as resolved.

// print debug symbols if they exist
if(not debug_symbols.empty())
{
std::cout << " # " << join_strings(debug_symbols, ", ");
}
std::cout << std::endl;
}

std::vector<instruction_ref> instruction::get_output_alias(instruction_ref ins, bool shallow)
Expand Down Expand Up @@ -578,6 +601,8 @@ static auto track_visits(instruction_ref start, instruction_ref end, F f)
std::size_t n = std::distance(start, end);
if(n < small)
{
// Stop condition is ins distance to end > N or
// same instruction already visited.
std::bitset<small> visited;
auto stop = [&](auto ins) {
auto i = std::distance(ins, end);
Expand All @@ -592,6 +617,9 @@ static auto track_visits(instruction_ref start, instruction_ref end, F f)
}
else
{
// Make a hashmap of instructions between start and end.
// Stop condition is instruction not in the hashmap or
// same instruction already visited.
auto instructions = range(start, std::next(end));
auto instruction_refs = iterator_for(instructions);
std::unordered_set<instruction_ref> in_range(instruction_refs.begin(),
Expand Down
Loading
Loading