Skip to content

Commit

Permalink
check symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
apwojcik committed Feb 3, 2025
1 parent 5cad3ec commit 4e6aa5c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ include(CheckLanguage)
include(CMakeDependentOption)
include(FetchContent)
include(CheckFunctionExists)
include(CheckSymbolExists)
include(GNUInstallDirs) # onnxruntime_providers_* require CMAKE_INSTALL_* variables

# TODO: update this once all system adapt c++20
Expand Down
9 changes: 9 additions & 0 deletions cmake/onnxruntime_providers_migraphx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
target_link_libraries(onnxruntime_providers_migraphx PRIVATE stdc++fs)
endif()

set(CMAKE_REQUIRED_LIBRARIES migraphx::c)

check_symbol_exists(migraphx_onnx_options_set_external_data_path
"migraphx/migraphx.h" HAVE_MIGRAPHX_API_ONNX_OPTIONS_SET_EXTERNAL_DATA_PATH)

if(HAVE_MIGRAPHX_API_ONNX_OPTIONS_SET_EXTERNAL_DATA_PATH)
target_compile_definitions(onnxruntime_providers_migraphx PRIVATE HAVE_MIGRAPHX_API_ONNX_OPTIONS_SET_EXTERNAL_DATA_PATH=1)
endif()

if (onnxruntime_ENABLE_TRAINING_OPS)
onnxruntime_add_include_to_target(onnxruntime_providers_migraphx onnxruntime_training)
target_link_libraries(onnxruntime_providers_migraphx PRIVATE onnxruntime_training)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,11 @@ Status MIGraphXExecutionProvider::Compile(const std::vector<FusedNodeAndGraph>&
if (!no_input_shape) {
if (!load_precompiled_model(prog, load_compiled_model_, std::string{load_compiled_path_})) {
LOGS_DEFAULT(INFO) << "No input shapes detected quantizing model";
#ifndef ENABLE_TRAINING_CORE
#ifdef HAVE_MIGRAPHX_API_ONNX_OPTIONS_SET_EXTERNAL_DATA_PATH
options.set_external_data_path(model_path_.parent_path().string());
#endif
#endif
prog = migraphx::parse_onnx_buffer(onnx_string_buffer, options);
migraphx::program_parameters quant_params;

Expand Down Expand Up @@ -1472,8 +1477,8 @@ Status MIGraphXExecutionProvider::Compile(const std::vector<FusedNodeAndGraph>&
if (!load_precompiled_model(prog, load_compiled_model_, std::string{load_compiled_path_})) {
LOGS_DEFAULT(VERBOSE) << "Input shape mismatch detected. Recompiling" << std::endl;
#ifndef ENABLE_TRAINING_CORE
#if HIP_VERSION_MAJOR > 6 || (HIP_VERSION_MAJOR == 6 && HIP_VERSION_MINOR >= 2)
cmp_options.set_external_data_path(model_path_.has_parent_path() ? model_path_.parent_path().string() : std::filesystem::current_path().string());
#ifdef HAVE_MIGRAPHX_API_ONNX_OPTIONS_SET_EXTERNAL_DATA_PATH
cmp_options.set_external_data_path(model_path_.parent_path().string());
#endif
#endif
prog = migraphx::parse_onnx_buffer(onnx_string, cmp_options);
Expand Down

0 comments on commit 4e6aa5c

Please sign in to comment.