Skip to content

Commit 17dcea7

Browse files
authored
Allow using extended minimal build for several EPs (#23834)
### Description #### Background From code search, the following EPs use `onnxruntime::GetCpuPreferredNodes()` in their `GetCapabilities()` methods: - CANN - CUDA - DML - JS - ROCM - WebGPU However, the source file that implements `onnxruntime::GetCpuPreferredNodes()` is excluded when minimal build is ON: https://github.com/microsoft/onnxruntime/blob/6df0973e58ba5399fcaa98686f70ed9a9e59aaef/cmake/onnxruntime_framework.cmake#L38-L42 This means that all EPs mentioned above is not able to compile with minimal build. #### Solution The excluded file `core/framework/fallback_cpu_capability.cc` cannot build in minimal build because some of its dependencies are not included in the minimal build. However, in extended minimal build mode, all dependencies are available. This PR looses the restrict and allows to compile this file when it is extended minimal build. After this change, those EPs are able to compile in extended minimal build.
1 parent bde4fbe commit 17dcea7

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

cmake/onnxruntime_framework.cmake

+1-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ elseif(onnxruntime_ENABLE_TRITON)
3636
endif()
3737

3838
if (onnxruntime_MINIMAL_BUILD)
39-
set(onnxruntime_framework_src_exclude
40-
"${ONNXRUNTIME_ROOT}/core/framework/fallback_cpu_capability.h"
41-
"${ONNXRUNTIME_ROOT}/core/framework/fallback_cpu_capability.cc"
42-
)
39+
set(onnxruntime_framework_src_exclude)
4340

4441
# custom ops support must be explicitly enabled in a minimal build. exclude if not.
4542
if (NOT onnxruntime_MINIMAL_BUILD_CUSTOM_OPS)

cmake/onnxruntime_providers_js.cmake

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
if (onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD)
5+
message(FATAL_ERROR "JSEP can not be used in a basic minimal build. Please build with '--minimal_build extended'")
6+
endif()
7+
48
add_compile_definitions(USE_JSEP=1)
59

610
file(GLOB_RECURSE onnxruntime_providers_js_cc_srcs
@@ -18,4 +22,4 @@
1822
onnxruntime_common onnxruntime_framework onnx onnx_proto ${PROTOBUF_LIB} flatbuffers Boost::mp11 Eigen3::Eigen
1923
)
2024

21-
add_dependencies(onnxruntime_providers_js ${onnxruntime_EXTERNAL_DEPENDENCIES})
25+
add_dependencies(onnxruntime_providers_js ${onnxruntime_EXTERNAL_DEPENDENCIES})

onnxruntime/core/framework/fallback_cpu_capability.cc

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
5+
46
#include "core/framework/fallback_cpu_capability.h"
57
#include "core/common/inlined_containers.h"
68

@@ -176,3 +178,5 @@ std::unordered_set<NodeIndex> GetCpuPreferredNodes(const onnxruntime::GraphViewe
176178
}
177179

178180
} // namespace onnxruntime
181+
182+
#endif // !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)

onnxruntime/core/framework/fallback_cpu_capability.h

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#pragma once
55

6+
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
7+
68
#include <gsl/gsl>
79
#include "core/common/inlined_containers_fwd.h"
810
#include "core/framework/execution_provider.h" // for IExecutionProvider::IKernelLookup
@@ -26,3 +28,5 @@ std::unordered_set<NodeIndex> GetCpuPreferredNodes(const GraphViewer& graph,
2628
const logging::Logger& logger);
2729

2830
} // namespace onnxruntime
31+
32+
#endif // !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)

0 commit comments

Comments
 (0)