Refine build script for adding disable selected data types option (#17284)

### Description
<!-- Describe your changes. -->

As title. 

### 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. -->

Now we have multiple data types that we want to disable for minimal
build and to reduce binary size. may be worth adding an argument in the
build script for specifying that.

Also for fp16 type stuff, it may be too restrict to disable that for all
minimal build.

---------

Co-authored-by: rachguo <rachguo@rachguos-Mac-mini.local>
This commit is contained in:
Rachel Guo 2023-08-31 13:32:55 -07:00 committed by GitHub
parent 30a450dcf8
commit b54619509f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 17 deletions

View file

@ -77,7 +77,6 @@ Abstract:
#define MLAS_SUPPORTS_GEMM_DOUBLE
#endif
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
#if (!defined(_MSC_VER)) || (_MSC_VER >= 1930)
#if defined(MLAS_TARGET_ARM64) || defined(MLAS_TARGET_ARM64EC)
#if !defined(__APPLE__)
@ -91,7 +90,6 @@ Abstract:
#endif //
#endif // ARM64
#endif // Visual Studio 16 or earlier does not support fp16 intrinsic
#endif // !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
//
// Basic Linear Algebra Subprograms (BLAS) types.

View file

@ -14,8 +14,6 @@ Abstract:
--*/
#if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)
#include "mlasi.h"
#include "halfgemm.h"
@ -187,5 +185,3 @@ const MLAS_HALFGEMM_DISPATCH MlasHalfGemmDispatchNeon = {
MLAS_HALF_GEMM_KERNEL_NEON::KernelMaxM,
32 // kernel may read beyond buffer end by 32 bytes
};
#endif // !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD)

View file

@ -626,6 +626,13 @@ def parse_arguments():
)
# Please note in our CMakeLists.txt this is already default on. But in this file we reverse it to default OFF.
parser.add_argument("--disable_rtti", action="store_true", help="Disable RTTI (reduces binary size)")
parser.add_argument(
"--disable_types",
nargs="+",
default=[],
choices=["float8", "optional", "sparsetensor"],
help="Disable selected data types (reduces binary size)",
)
parser.add_argument(
"--disable_exceptions",
action="store_true",
@ -889,8 +896,11 @@ def generate_build_tree(
if not use_dev_mode(args):
cmake_args += ["--compile-no-warning-as-error"]
types_to_disable = args.disable_types
# enable/disable float 8 types
disable_float8_types = args.use_rocm or args.android or args.minimal_build
disable_float8_types = args.use_rocm or args.android or ("float8" in types_to_disable)
disable_optional_type = "optional" in types_to_disable
disable_sparse_tensors = "sparsetensor" in types_to_disable
cmake_args += [
"-Donnxruntime_RUN_ONNX_TESTS=" + ("ON" if args.enable_onnx_tests else "OFF"),
@ -990,6 +1000,8 @@ def generate_build_tree(
"-Donnxruntime_USE_CANN=" + ("ON" if args.use_cann else "OFF"),
"-Donnxruntime_USE_TRITON_KERNEL=" + ("ON" if args.use_triton_kernel else "OFF"),
"-Donnxruntime_DISABLE_FLOAT8_TYPES=" + ("ON" if disable_float8_types else "OFF"),
"-Donnxruntime_DISABLE_SPARSE_TENSORS=" + ("ON" if disable_sparse_tensors else "OFF"),
"-Donnxruntime_DISABLE_OPTIONAL_TYPE=" + ("ON" if disable_optional_type else "OFF"),
]
# By default on Windows we currently support only cross compiling for ARM/ARM64

View file

@ -247,11 +247,9 @@ jobs:
--parallel \
--skip_tests \
--disable_ml_ops \
--disable_types sparsetensor float8 optional \
--include_ops_by_config /home/onnxruntimedev/.test_data/include_no_operators.config \
--cmake_extra_defines onnxruntime_DISABLE_SPARSE_TENSORS=ON \
onnxruntime_DISABLE_FLOAT8_TYPES=ON \
onnxruntime_DISABLE_OPTIONAL_TYPE=ON \
onnxruntime_BUILD_UNIT_TESTS=OFF
--cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF
workingDirectory: $(Build.SourcesDirectory)
- task: CmdLine@2
@ -278,10 +276,9 @@ jobs:
--disable_ml_ops \
--skip_tests \
--enable_reduced_operator_type_support \
--disable_types sparsetensor optional float8 \
--include_ops_by_config /home/onnxruntimedev/.test_data/include_no_operators.config \
--cmake_extra_defines onnxruntime_DISABLE_SPARSE_TENSORS=ON \
onnxruntime_DISABLE_OPTIONAL_TYPE=ON \
onnxruntime_BUILD_UNIT_TESTS=OFF
--cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF
workingDirectory: $(Build.SourcesDirectory)
- task: CmdLine@2
@ -308,10 +305,9 @@ jobs:
--disable_ml_ops \
--skip_tests \
--enable_reduced_operator_type_support \
--disable_types sparsetensor optional float8 \
--include_ops_by_config /home/onnxruntimedev/.test_data/include_no_operators.config \
--cmake_extra_defines onnxruntime_DISABLE_SPARSE_TENSORS=ON \
onnxruntime_DISABLE_OPTIONAL_TYPE=ON \
onnxruntime_BUILD_UNIT_TESTS=OFF
--cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF
workingDirectory: $(Build.SourcesDirectory)
- task: CmdLine@2