Skip to content

Commit 87533ff

Browse files
Initial changes to API to get onnx names out
1 parent 6fe8b02 commit 87533ff

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
lines changed

src/api/api.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ static void quantize_fp8_wrap(program& prog, const target& t, quantize_fp8_optio
289289
migraphx::quantize_fp8(prog, t, options.calibration);
290290
}
291291

292+
static std::vector<std::string> get_supported_onnx_operators()
293+
{
294+
return migraphx::get_onnx_operators();
295+
}
296+
292297
#ifdef __clang__
293298
#pragma clang diagnostic push
294299
#pragma clang diagnostic ignored "-Wformat-nonliteral"
@@ -733,6 +738,17 @@ struct migraphx_quantize_fp8_options
733738
migraphx::quantize_fp8_options object;
734739
};
735740

741+
extern "C" struct migraphx_get_supported_onnx_operators;
742+
struct migraphx_get_supported_onnx_operators
743+
{
744+
template <class... Ts>
745+
migraphx_get_supported_onnx_operators(Ts&&... xs)
746+
: object(std::forward<Ts>(xs)...) // NOLINT(readability-redundant-member-init)
747+
{
748+
}
749+
migraphx::get_supported_onnx_operators object;
750+
};
751+
736752
extern "C" struct migraphx_context;
737753
struct migraphx_context
738754
{
@@ -2418,6 +2434,32 @@ extern "C" migraphx_status migraphx_quantize_fp8(migraphx_program_t prog,
24182434
return api_error_result;
24192435
}
24202436

2437+
extern "C" migraphx_status migraphx_get_supported_onnx_operators_destroy(
2438+
migraphx_get_supported_onnx_operators_t get_supported_onnx_operators)
2439+
{
2440+
auto api_error_result = migraphx::try_([&] { destroy((get_supported_onnx_operators)); });
2441+
return api_error_result;
2442+
}
2443+
2444+
extern "C" migraphx_status
2445+
migraphx_get_supported_onnx_operators_assign_to(migraphx_get_supported_onnx_operators_t output,
2446+
const_migraphx_get_supported_onnx_operators_t input)
2447+
{
2448+
auto api_error_result = migraphx::try_([&] { *output = *input; });
2449+
return api_error_result;
2450+
}
2451+
2452+
extern "C" migraphx_status migraphx_get_supported_onnx_operators_create(
2453+
migraphx_get_supported_onnx_operators_t* get_supported_onnx_operators)
2454+
{
2455+
auto api_error_result = migraphx::try_([&] {
2456+
*get_supported_onnx_operators = object_cast<migraphx_get_supported_onnx_operators_t>(
2457+
allocate<migraphx::get_supported_onnx_operators>(
2458+
migraphx::get_supported_onnx_operators()));
2459+
});
2460+
return api_error_result;
2461+
}
2462+
24212463
extern "C" migraphx_status migraphx_context_finish(const_migraphx_context_t context)
24222464
{
24232465
auto api_error_result = migraphx::try_([&] {

src/api/include/migraphx/migraphx.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ typedef const struct migraphx_quantize_int8_options* const_migraphx_quantize_int
145145
typedef struct migraphx_quantize_fp8_options* migraphx_quantize_fp8_options_t;
146146
typedef const struct migraphx_quantize_fp8_options* const_migraphx_quantize_fp8_options_t;
147147

148+
typedef struct migraphx_get_supported_onnx_operators* migraphx_get_supported_onnx_operators_t;
149+
typedef const struct migraphx_get_supported_onnx_operators*
150+
const_migraphx_get_supported_onnx_operators_t;
151+
148152
typedef struct migraphx_context* migraphx_context_t;
149153
typedef const struct migraphx_context* const_migraphx_context_t;
150154

@@ -659,6 +663,16 @@ MIGRAPHX_C_EXPORT migraphx_status migraphx_quantize_fp8(migraphx_program_t prog,
659663
migraphx_target_t target,
660664
migraphx_quantize_fp8_options_t options);
661665

666+
MIGRAPHX_C_EXPORT migraphx_status migraphx_get_supported_onnx_operators_destroy(
667+
migraphx_get_supported_onnx_operators_t get_supported_onnx_operators);
668+
669+
MIGRAPHX_C_EXPORT migraphx_status migraphx_get_supported_onnx_operators_assign_to(
670+
migraphx_get_supported_onnx_operators_t output,
671+
const_migraphx_get_supported_onnx_operators_t input);
672+
673+
MIGRAPHX_C_EXPORT migraphx_status migraphx_get_supported_onnx_operators_create(
674+
migraphx_get_supported_onnx_operators_t* get_supported_onnx_operators);
675+
662676
MIGRAPHX_C_EXPORT migraphx_status migraphx_context_finish(const_migraphx_context_t context);
663677

664678
MIGRAPHX_C_EXPORT migraphx_status migraphx_context_get_queue(void** out,

src/api/include/migraphx/migraphx.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,19 @@ quantize_fp8(const program& prog, const target& ptarget, const quantize_fp8_opti
16031603
options.get_handle_ptr());
16041604
}
16051605

1606+
struct supported_onnx_ops_options : MIGRPAHX_HANDLE_BASE(supported_onnx_ops_options)
1607+
{
1608+
supported_onnx_ops-options() {this->make_handle(&migraphx_supported_onnx_ops_options_create); }
1609+
1610+
MIGRAPHX_HANDLE_CONSTRUCTOR(supported_onnx_op_options)
1611+
};
1612+
1613+
inline void get_supported_onnx_operators(supported_onnx_ops_options& options)
1614+
{
1615+
call(&migraphx_get_onnx_operators,
1616+
options.get_handle_ptr());
1617+
}
1618+
16061619
struct experimental_custom_op_base
16071620
{
16081621
experimental_custom_op_base() = default;
@@ -1618,6 +1631,7 @@ struct experimental_custom_op_base
16181631
virtual bool runs_on_offload_target() const = 0;
16191632
};
16201633

1634+
16211635
struct experimental_custom_op : interface_base<MIGRAPHX_HANDLE_BASE(experimental_custom_op)>
16221636
{
16231637
template <class T>

src/api/migraphx.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,11 @@ def quantize_fp8_options(h):
510510
options='migraphx::quantize_fp8_options'),
511511
fname='migraphx::quantize_fp8_wrap')
512512

513+
@auto_handle()
514+
def get_supported_onnx_operators(h):
515+
h.constructor('create',
516+
fname='migraphx::get_supported_onnx_operators')
517+
513518

514519
@auto_handle(ref=True)
515520
def context(h):

src/py/migraphx_py.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ MIGRAPHX_PYBIND11_MODULE(migraphx, m)
621621
py::arg("map_input_dims") = std::unordered_map<std::string, std::vector<std::size_t>>(),
622622
py::arg("output_names") = std::vector<std::string>());
623623

624+
m.def("get_supported_onnx_operators", []{return migraphx::get_onnx_operators();});
624625
m.def(
625626
"parse_onnx",
626627
[](const std::string& filename,

tools/api/api.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ static void quantize_fp8_wrap(program& prog, const target& t, quantize_fp8_optio
289289
migraphx::quantize_fp8(prog, t, options.calibration);
290290
}
291291

292+
static std::vector<std::string> get_supported_onnx_operators()
293+
{
294+
return migraphx::get_onnx_operators();
295+
}
296+
292297
#ifdef __clang__
293298
#pragma clang diagnostic push
294299
#pragma clang diagnostic ignored "-Wformat-nonliteral"

0 commit comments

Comments
 (0)