Skip to content

Commit c0d10fe

Browse files
Handle output
1 parent 17a06a1 commit c0d10fe

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

src/api/api.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ static void quantize_fp8_wrap(program& prog, const target& t, quantize_fp8_optio
291291

292292
static size_t get_onnx_operators_size() { return migraphx::get_onnx_operators().size(); }
293293

294-
static const char* get_onnx_operator_name_at_index(std::size_t index)
294+
static char* get_onnx_operator_name_at_index(std::size_t index)
295295
{
296-
return get_onnx_operators().at(index).c_str();
296+
return const_cast<char*>(get_onnx_operators().at(index).c_str());
297297
}
298298

299299
#ifdef __clang__
@@ -2423,14 +2423,14 @@ extern "C" migraphx_status migraphx_quantize_fp8(migraphx_program_t prog,
24232423
return api_error_result;
24242424
}
24252425

2426-
extern "C" migraphx_status migraphx_get_onnx_operator_name_at_index(const char** out, size_t index)
2426+
extern "C" migraphx_status migraphx_get_onnx_operator_name_at_index(char** out, size_t index)
24272427
{
24282428
auto api_error_result =
24292429
migraphx::try_([&] { *out = migraphx::get_onnx_operator_name_at_index((index)); });
24302430
return api_error_result;
24312431
}
24322432

2433-
extern "C" migraphx_status migraphx_get_onnx_operators_size(std::size_t* out)
2433+
extern "C" migraphx_status migraphx_get_onnx_operators_size(size_t* out)
24342434
{
24352435
auto api_error_result = migraphx::try_([&] { *out = migraphx::get_onnx_operators_size(); });
24362436
return api_error_result;

src/api/include/migraphx/migraphx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,10 @@ MIGRAPHX_C_EXPORT migraphx_status migraphx_quantize_fp8(migraphx_program_t prog,
659659
migraphx_target_t target,
660660
migraphx_quantize_fp8_options_t options);
661661

662-
MIGRAPHX_C_EXPORT migraphx_status migraphx_get_onnx_operator_name_at_index(const char** out,
662+
MIGRAPHX_C_EXPORT migraphx_status migraphx_get_onnx_operator_name_at_index(char** out,
663663
size_t index);
664664

665-
MIGRAPHX_C_EXPORT migraphx_status migraphx_get_onnx_operators_size(std::size_t* out);
665+
MIGRAPHX_C_EXPORT migraphx_status migraphx_get_onnx_operators_size(size_t* out);
666666

667667
MIGRAPHX_C_EXPORT migraphx_status migraphx_context_finish(const_migraphx_context_t context);
668668

src/api/include/migraphx/migraphx.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,15 +1643,18 @@ void register_experimental_custom_op(T& obj)
16431643
op.register_op();
16441644
}
16451645

1646-
std::vector<const char *> get_onnx_operators()
1646+
inline std::vector<std::string> get_onnx_operators()
16471647
{
1648-
auto size = get_onnx_operators_size();
1649-
std::vector<const char *> result(size, "");
1648+
size_t size = 0;
1649+
migraphx_get_onnx_operators_size(&size);
1650+
std::vector<std::string> result(size, "");
16501651

16511652
size_t index = 0;
16521653
for(auto &name: result)
16531654
{
1654-
name= get_onnx_operator_name_at_index(index);
1655+
char * name_op;
1656+
migraphx_get_onnx_operator_name_at_index(&name_op, index);
1657+
name = *name_op;
16551658
index++;
16561659
}
16571660
return result;

src/api/migraphx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,11 @@ def quantize_fp8_options(h):
513513
api.add_function('migraphx_get_onnx_operator_name_at_index',
514514
api.params(index='size_t'),
515515
fname='migraphx::get_onnx_operator_name_at_index',
516-
returns='const char *')
516+
returns='char *')
517517

518518
api.add_function('migraphx_get_onnx_operators_size',
519519
fname='migraphx::get_onnx_operators_size',
520-
returns='std::size_t')
520+
returns='size_t')
521521

522522

523523

tools/api/api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ static size_t get_onnx_operators_size()
294294
return migraphx::get_onnx_operators().size();
295295
}
296296

297-
static const char * get_onnx_operator_name_at_index(std::size_t index)
297+
static char * get_onnx_operator_name_at_index(std::size_t index)
298298
{
299-
return get_onnx_operators().at(index).c_str();
299+
return const_cast<char*>(get_onnx_operators().at(index).c_str());
300300
}
301301

302302
#ifdef __clang__

0 commit comments

Comments
 (0)