Skip to content

Commit c7f86b3

Browse files
authored
Built-in onnxruntime-extensions updates (microsoft#24892)
### Description <!-- Describe your changes. --> - Fix onnxruntime-extensions include path. - Add option to onnxruntime_perf_test to register custom ops from a built-in onnxruntime-extensions. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Fix build.py `--use_extensions` option. Make it simple to use the built-in onnxruntime-extensions with onnxruntime_perf_test.
1 parent 9d6546e commit c7f86b3

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

cmake/external/extensions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ set_target_properties(ortcustomops PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "")
6969

7070
# target library or executable are defined in CMakeLists.txt of onnxruntime-extensions
7171
target_include_directories(ocos_operators PRIVATE ${RE2_INCLUDE_DIR} ${json_SOURCE_DIR}/include)
72-
target_include_directories(ortcustomops PUBLIC $<BUILD_INTERFACE:${onnxruntime_EXTENSIONS_PATH}/includes>)
72+
target_include_directories(ortcustomops PUBLIC $<BUILD_INTERFACE:${onnxruntime_EXTENSIONS_PATH}/include>)
7373
if(OCOS_ENABLE_SPM_TOKENIZER)
7474
onnxruntime_add_include_to_target(sentencepiece-static ${PROTOBUF_LIB} ${ABSEIL_LIBS})
7575
endif()

onnxruntime/test/perftest/command_args_parser.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ namespace perftest {
161161
"\t-n [Exit after session creation]: allow user to measure session creation time to measure impact of enabling any initialization optimizations.\n"
162162
"\t-l Provide file as binary in memory by using fopen before session creation.\n"
163163
"\t-R [Register custom op]: allow user to register custom op by .so or .dll file.\n"
164+
"\t-X [Enable onnxruntime-extensions custom ops]: Registers custom ops from onnxruntime-extensions. "
165+
"onnxruntime-extensions must have been built in to onnxruntime. This can be done with the build.py "
166+
"'--use_extensions' option.\n"
164167
"\t-h: help\n");
165168
}
166169
#ifdef _WIN32
@@ -190,7 +193,7 @@ static bool ParseDimensionOverride(std::basic_string<ORTCHAR_T>& dim_identifier,
190193

191194
/*static*/ bool CommandLineParser::ParseArguments(PerformanceTestConfig& test_config, int argc, ORTCHAR_T* argv[]) {
192195
int ch;
193-
while ((ch = getopt(argc, argv, ORT_TSTR("m:e:r:t:p:x:y:c:d:o:u:i:f:F:S:T:C:AMPIDZvhsqznlgR:"))) != -1) {
196+
while ((ch = getopt(argc, argv, ORT_TSTR("m:e:r:t:p:x:y:c:d:o:u:i:f:F:S:T:C:AMPIDZvhsqznlgR:X"))) != -1) {
194197
switch (ch) {
195198
case 'f': {
196199
std::basic_string<ORTCHAR_T> dim_name;
@@ -393,6 +396,9 @@ static bool ParseDimensionOverride(std::basic_string<ORTCHAR_T>& dim_identifier,
393396
case 'g':
394397
test_config.run_config.enable_cuda_io_binding = true;
395398
break;
399+
case 'X':
400+
test_config.run_config.use_extensions = true;
401+
break;
396402
case '?':
397403
case 'h':
398404
default:

onnxruntime/test/perftest/ort_test_session.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,10 @@ select from 'TF8', 'TF16', 'UINT8', 'FLOAT', 'ITENSOR'. \n)");
826826
#endif
827827
}
828828

829+
if (performance_test_config.run_config.use_extensions) {
830+
session_options.EnableOrtCustomOps();
831+
}
832+
829833
if (!performance_test_config.model_info.load_via_path) {
830834
session_ = Ort::Session(env, performance_test_config.model_info.model_file_path.c_str(), session_options);
831835
} else {

onnxruntime/test/perftest/test_configuration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct RunConfig {
6767
bool exit_after_session_creation = false;
6868
std::basic_string<ORTCHAR_T> register_custom_op_path;
6969
bool enable_cuda_io_binding{false};
70+
bool use_extensions = false;
7071
};
7172

7273
struct PerformanceTestConfig {

0 commit comments

Comments
 (0)