From 1a34775fe97f16f332efa7d58ef5f44b716de066 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Thu, 2 Sep 2021 10:36:24 -0700 Subject: [PATCH] Fix the benchmark code (#8926) --- cmake/onnxruntime_unittests.cmake | 2 +- onnxruntime/test/onnx/microbenchmark/activation.cc | 10 +++++++++- .../github/azure-pipelines/linux-ci-pipeline.yml | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake index 696d32277d..d5e64523f0 100644 --- a/cmake/onnxruntime_unittests.cmake +++ b/cmake/onnxruntime_unittests.cmake @@ -853,7 +853,7 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP) file(GLOB_RECURSE MLAS_BENCH_SOURCE_FILES "${MLAS_BENCH_DIR}/*.cpp" "${MLAS_BENCH_DIR}/*.h") onnxruntime_add_executable(onnxruntime_mlas_benchmark ${MLAS_BENCH_SOURCE_FILES}) target_include_directories(onnxruntime_mlas_benchmark PRIVATE ${ONNXRUNTIME_ROOT}/core/mlas/inc) - target_link_libraries(onnxruntime_mlas_benchmark PRIVATE benchmark::benchmark onnxruntime_mlas onnxruntime_common onnxruntime_framework onnxruntime_util) + target_link_libraries(onnxruntime_mlas_benchmark PRIVATE benchmark::benchmark onnxruntime_util onnxruntime_framework onnxruntime_mlas onnxruntime_common ${CMAKE_DL_LIBS}) if(NOT WIN32) target_link_libraries(onnxruntime_mlas_benchmark PRIVATE nsync_cpp) endif() diff --git a/onnxruntime/test/onnx/microbenchmark/activation.cc b/onnxruntime/test/onnx/microbenchmark/activation.cc index 4abe4575a4..06bae6929c 100644 --- a/onnxruntime/test/onnx/microbenchmark/activation.cc +++ b/onnxruntime/test/onnx/microbenchmark/activation.cc @@ -86,9 +86,17 @@ class MyIExecutionFrame : public IExecutionFrame { const OrtValueNameIdxMap& ort_value_idx_map, const NodeIndexInfo& node_index_info) : IExecutionFrame(ort_value_idx_map, node_index_info, fetch_mlvalue_idxs), a_(a) { - Init(feed_mlvalue_idxs, feeds, initializers, fetches); + Init( + feed_mlvalue_idxs, feeds, initializers, [](const std::string& name) -> bool { return false; }, fetches); } + const DataTransferManager& GetDataTransferManager() const override { + abort(); + } + + Status CreateNodeOutputMLValueImpl(OrtValue& ort_value, int ort_value_idx, const TensorShape* shape) override { + abort(); + } AllocatorPtr GetAllocatorImpl(const OrtMemoryInfo& info) const { return a_.GetAllocator(info.id, info.mem_type); } diff --git a/tools/ci_build/github/azure-pipelines/linux-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/linux-ci-pipeline.yml index c3f109793c..4d8bfb4287 100644 --- a/tools/ci_build/github/azure-pipelines/linux-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/linux-ci-pipeline.yml @@ -43,7 +43,7 @@ jobs: --build_wheel \ --enable_onnx_tests \ --enable_transformers_tool_test \ - --build_java --build_nodejs --update --build + --build_java --build_nodejs --update --build --cmake_extra_defines onnxruntime_BUILD_BENCHMARKS=ON workingDirectory: $(Build.SourcesDirectory) - task: CmdLine@2