diff --git a/.github/workflows/linux_minimal_build.yml b/.github/workflows/linux_minimal_build.yml index 7d481475e7ded..4058e7af99070 100644 --- a/.github/workflows/linux_minimal_build.yml +++ b/.github/workflows/linux_minimal_build.yml @@ -346,7 +346,7 @@ jobs: --build_wheel --use_binskim_compliant_compile_flags --disable_ml_ops - --disable_types sparsetensor float4 float8 optional + --disable_types string sparsetensor float4 float8 optional --include_ops_by_config /onnxruntime_src/build/.test_data/include_no_operators.config --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF @@ -361,7 +361,7 @@ jobs: --build_wheel --use_binskim_compliant_compile_flags --disable_ml_ops - --disable_types sparsetensor float4 float8 optional + --disable_types string sparsetensor float4 float8 optional --include_ops_by_config /onnxruntime_src/build/.test_data/include_no_operators.config --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF @@ -377,7 +377,7 @@ jobs: --build_wheel --use_binskim_compliant_compile_flags --disable_ml_ops - --disable_types sparsetensor float4 float8 optional + --disable_types string sparsetensor float4 float8 optional --include_ops_by_config /onnxruntime_src/build/.test_data/include_no_operators.config --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF @@ -430,7 +430,7 @@ jobs: --disable_ml_ops --skip_tests --enable_reduced_operator_type_support - --disable_types sparsetensor optional float4 float8 + --disable_types string sparsetensor optional float4 float8 --include_ops_by_config /onnxruntime_src/build/.test_data/include_no_operators.config --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF @@ -448,7 +448,7 @@ jobs: --disable_ml_ops --skip_tests --enable_reduced_operator_type_support - --disable_types sparsetensor optional float4 float8 + --disable_types string sparsetensor optional float4 float8 --include_ops_by_config /onnxruntime_src/build/.test_data/include_no_operators.config --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF @@ -507,7 +507,7 @@ jobs: --disable_ml_ops --skip_tests --enable_reduced_operator_type_support - --disable_types sparsetensor optional float4 float8 + --disable_types string sparsetensor optional float4 float8 --include_ops_by_config /onnxruntime_src/build/.test_data/include_no_operators.config --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF @@ -525,7 +525,7 @@ jobs: --disable_ml_ops --skip_tests --enable_reduced_operator_type_support - --disable_types sparsetensor optional float4 float8 + --disable_types string sparsetensor optional float4 float8 --include_ops_by_config /onnxruntime_src/build/.test_data/include_no_operators.config --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 11244e46b78a0..95c654649fdbc 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -163,6 +163,7 @@ option(onnxruntime_DISABLE_SPARSE_TENSORS "Disable sparse tensors data types" OF option(onnxruntime_DISABLE_OPTIONAL_TYPE "Disable optional type" OFF) option(onnxruntime_DISABLE_FLOAT8_TYPES "Disable float 8 types" OFF) option(onnxruntime_DISABLE_FLOAT4_TYPES "Disable float 4 types" OFF) +option(onnxruntime_DISABLE_STRING_TYPE "Disable string type" OFF) option(onnxruntime_MINIMAL_BUILD "Exclude as much as possible from the build. Support ORT format models. No support for ONNX format models." OFF) option(onnxruntime_CLIENT_PACKAGE_BUILD "Enables default settings that are more appropriate for client/on-device workloads." OFF) cmake_dependent_option(onnxruntime_DISABLE_RTTI "Disable RTTI" ON "NOT onnxruntime_ENABLE_PYTHON;NOT onnxruntime_USE_CUDA" OFF) @@ -1079,6 +1080,10 @@ function(onnxruntime_set_compile_flags target_name) target_compile_definitions(${target_name} PRIVATE DISABLE_FLOAT4_TYPES) endif() + if (onnxruntime_DISABLE_STRING_TYPE) + target_compile_definitions(${target_name} PRIVATE DISABLE_STRING_TYPE) + endif() + if (onnxruntime_ENABLE_ATEN) target_compile_definitions(${target_name} PRIVATE ENABLE_ATEN) endif() diff --git a/onnxruntime/contrib_ops/cpu/cpu_contrib_kernels.cc b/onnxruntime/contrib_ops/cpu/cpu_contrib_kernels.cc index d959d11e3fd43..0c241f7644a84 100644 --- a/onnxruntime/contrib_ops/cpu/cpu_contrib_kernels.cc +++ b/onnxruntime/contrib_ops/cpu/cpu_contrib_kernels.cc @@ -313,7 +313,9 @@ Status RegisterCpuContribKernels(KernelRegistry& kernel_registry) { BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, diff --git a/onnxruntime/core/providers/cpu/cpu_execution_provider.cc b/onnxruntime/core/providers/cpu/cpu_execution_provider.cc index f6484ab60f5da..2a67b008f849d 100644 --- a/onnxruntime/core/providers/cpu/cpu_execution_provider.cc +++ b/onnxruntime/core/providers/cpu/cpu_execution_provider.cc @@ -308,7 +308,9 @@ class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOn class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 8, 12, uint64_t, Expand); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 8, 12, bool, Expand); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 8, 12, MLFloat16, Expand); +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 8, 12, string, Expand); +#endif class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 8, 8, Scan); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 1, 10, If); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 1, 10, Loop); @@ -348,10 +350,12 @@ class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOn int64_t_int64_t_int64_t, OneHot); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 10, float_int64_t_int64_t, OneHot); +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 10, int64_t_string_int64_t, OneHot); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 10, float_string_int64_t, OneHot); +#endif class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 10, float_float_float, OneHot); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 10, int64_t_int32_t_float, @@ -374,13 +378,17 @@ class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDoma class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 21, Atanh); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 10, Scan); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 10, Scatter); +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, TfIdfVectorizer); +#endif class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 12, bool, NonZero); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 12, float, NonZero); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 12, int32_t, NonZero); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 12, int64_t, NonZero); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 12, uint8_t, NonZero); +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 15, string, Where); +#endif class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 15, float, Where); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 15, double, Where); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 15, int32_t, Where); @@ -404,7 +412,9 @@ class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOn class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 9, 9, uint8_t, Upsample); // Opset 10 +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, StringNormalizer); +#endif class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, 10, float, TopK); class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, 10, double, TopK); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 10, 10, AveragePool); @@ -579,8 +589,10 @@ class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOn class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, 23, int32_t, TopK); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, int64_t_int64_t_int64_t, OneHot); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, float_int64_t_int64_t, OneHot); +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, int64_t_string_int64_t, OneHot); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, float_string_int64_t, OneHot); +#endif class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, float_float_float, OneHot); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, int64_t_int32_t_float, OneHot); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 11, int64_t_float_int64_t, OneHot); @@ -689,7 +701,9 @@ class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, uint64_t, Expand); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, bool, Expand); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, MLFloat16, Expand); +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, string, Expand); +#endif class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, float, Gemm); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, double, Gemm); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 13, float, MatMul); @@ -1010,7 +1024,9 @@ class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, class ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 16, 19, float, GridSample); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 16, 17, ScatterElements); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 16, 17, ScatterND); +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 16, string, Where); +#endif class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 16, float, Where); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 16, double, Where); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 16, int32_t, Where); @@ -1176,7 +1192,9 @@ class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 19, uint64_t, Equal); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 19, float, Equal); class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 19, double, Equal); +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 19, string, Equal); +#endif class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 19, 20, Identity); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 19, 20, If); class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 19, 20, Loop); @@ -1236,9 +1254,11 @@ class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, class ONNX_OPERATOR_TYPED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, Float8E5M2FNUZ, IsNaN); #endif class ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, IsInf); +#if !defined(DISABLE_STRING_TYPE) class ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, StringConcat); class ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, RegexFullMatch); class ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 20, StringSplit); +#endif // Opset 21 class ONNX_OPERATOR_VERSIONED_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 21, 22, Cast); @@ -1909,8 +1929,10 @@ Status RegisterOnnxOperatorKernels(KernelRegistry& kernel_registry) { bool, Expand)>, BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, @@ -1977,10 +1999,12 @@ Status RegisterOnnxOperatorKernels(KernelRegistry& kernel_registry) { int64_t_int64_t_int64_t, OneHot)>, BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, BuildKernelCreateInfo, - // Opset 10 + // Opset 10 +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, // REVIEW(codemzs): ConstEigenVectorArrayMap.cast, BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, +#endif BuildKernelCreateInfo, BuildKernelCreateInfo, @@ -3283,9 +3321,11 @@ Status RegisterOnnxOperatorKernels(KernelRegistry& kernel_registry) { IsNaN)>, #endif BuildKernelCreateInfo, +#if !defined(DISABLE_STRING_TYPE) BuildKernelCreateInfo, BuildKernelCreateInfo, BuildKernelCreateInfo, +#endif // Opset 21 BuildKernelCreateInfo, diff --git a/onnxruntime/core/providers/cpu/nn/tfidfvectorizer.cc b/onnxruntime/core/providers/cpu/nn/tfidfvectorizer.cc index 60acd870eb43c..83e6069748646 100644 --- a/onnxruntime/core/providers/cpu/nn/tfidfvectorizer.cc +++ b/onnxruntime/core/providers/cpu/nn/tfidfvectorizer.cc @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#if !defined(DISABLE_STRING_TYPE) + #include "tfidfvectorizer.h" #include "core/common/common.h" #include "core/common/inlined_containers.h" @@ -430,3 +432,5 @@ Status TfIdfVectorizer::Compute(OpKernelContext* ctx) const { } } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/onnxruntime/core/providers/cpu/nn/tfidfvectorizer.h b/onnxruntime/core/providers/cpu/nn/tfidfvectorizer.h index 14488d91c23e9..cd5892d9c88c0 100644 --- a/onnxruntime/core/providers/cpu/nn/tfidfvectorizer.h +++ b/onnxruntime/core/providers/cpu/nn/tfidfvectorizer.h @@ -3,6 +3,8 @@ #pragma once +#if !defined(DISABLE_STRING_TYPE) + #include "core/common/common.h" #include "core/framework/op_kernel.h" #include @@ -27,3 +29,5 @@ class TfIdfVectorizer final : public OpKernel { }; } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/onnxruntime/core/providers/cpu/text/regex_full_match.cc b/onnxruntime/core/providers/cpu/text/regex_full_match.cc index cc4a5a9ae4e61..321bae1b09020 100644 --- a/onnxruntime/core/providers/cpu/text/regex_full_match.cc +++ b/onnxruntime/core/providers/cpu/text/regex_full_match.cc @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#if !defined(DISABLE_STRING_TYPE) + #include "regex_full_match.h" #include "core/common/common.h" @@ -33,3 +35,5 @@ Status RegexFullMatch::Compute(OpKernelContext* context) const { } } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/onnxruntime/core/providers/cpu/text/regex_full_match.h b/onnxruntime/core/providers/cpu/text/regex_full_match.h index 0d3f1f4b4b824..506ee93daf80e 100644 --- a/onnxruntime/core/providers/cpu/text/regex_full_match.h +++ b/onnxruntime/core/providers/cpu/text/regex_full_match.h @@ -3,6 +3,8 @@ #pragma once +#if !defined(DISABLE_STRING_TYPE) + #include "core/framework/op_kernel.h" #include "re2/re2.h" @@ -18,3 +20,5 @@ class RegexFullMatch final : public OpKernel { }; } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/onnxruntime/core/providers/cpu/text/string_concat.cc b/onnxruntime/core/providers/cpu/text/string_concat.cc index bc626f8e055aa..3b27ce3180430 100644 --- a/onnxruntime/core/providers/cpu/text/string_concat.cc +++ b/onnxruntime/core/providers/cpu/text/string_concat.cc @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#if !defined(DISABLE_STRING_TYPE) + #include "string_concat.h" #include "core/providers/cpu/math/element_wise_ops.h" #include "core/common/common.h" @@ -58,3 +60,5 @@ Status StringConcat::Compute(OpKernelContext* context) const { } } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/onnxruntime/core/providers/cpu/text/string_concat.h b/onnxruntime/core/providers/cpu/text/string_concat.h index 63c1ea8a41146..9840076fe2a5b 100644 --- a/onnxruntime/core/providers/cpu/text/string_concat.h +++ b/onnxruntime/core/providers/cpu/text/string_concat.h @@ -3,6 +3,8 @@ #pragma once +#if !defined(DISABLE_STRING_TYPE) + #include "core/framework/op_kernel.h" namespace onnxruntime { @@ -15,3 +17,5 @@ class StringConcat final : public OpKernel { }; } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/onnxruntime/core/providers/cpu/text/string_normalizer.cc b/onnxruntime/core/providers/cpu/text/string_normalizer.cc index 9bc671f68f19a..8722c335a96a2 100644 --- a/onnxruntime/core/providers/cpu/text/string_normalizer.cc +++ b/onnxruntime/core/providers/cpu/text/string_normalizer.cc @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#if !defined(DISABLE_STRING_TYPE) + #include "string_normalizer.h" #include "core/common/common.h" #include "core/framework/tensor.h" @@ -635,3 +637,5 @@ Status StringNormalizer::Compute(OpKernelContext* ctx) const { return status; } } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/onnxruntime/core/providers/cpu/text/string_normalizer.h b/onnxruntime/core/providers/cpu/text/string_normalizer.h index 9759140847b3a..4e66a66b00893 100644 --- a/onnxruntime/core/providers/cpu/text/string_normalizer.h +++ b/onnxruntime/core/providers/cpu/text/string_normalizer.h @@ -3,6 +3,8 @@ #pragma once +#if !defined(DISABLE_STRING_TYPE) + #include "core/common/inlined_containers.h" #include "core/framework/op_kernel.h" @@ -37,3 +39,5 @@ class StringNormalizer : public OpKernel { }; } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/onnxruntime/core/providers/cpu/text/string_split.cc b/onnxruntime/core/providers/cpu/text/string_split.cc index 2b82309838464..bf0e797b68df4 100644 --- a/onnxruntime/core/providers/cpu/text/string_split.cc +++ b/onnxruntime/core/providers/cpu/text/string_split.cc @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#if !defined(DISABLE_STRING_TYPE) + #include "string_split.h" #include #include @@ -96,3 +98,5 @@ Status StringSplit::Compute(OpKernelContext* context) const { } } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/onnxruntime/core/providers/cpu/text/string_split.h b/onnxruntime/core/providers/cpu/text/string_split.h index 6be249261d4e3..4199d258b17bf 100644 --- a/onnxruntime/core/providers/cpu/text/string_split.h +++ b/onnxruntime/core/providers/cpu/text/string_split.h @@ -3,6 +3,8 @@ #pragma once +#if !defined(DISABLE_STRING_TYPE) + #include "core/framework/op_kernel.h" namespace onnxruntime { @@ -18,3 +20,5 @@ class StringSplit final : public OpKernel { }; } // namespace onnxruntime + +#endif // !defined(DISABLE_STRING_TYPE) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 05e1f96b7610c..527fa5596b84a 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -373,6 +373,7 @@ def generate_build_tree( disable_float4_types = args.android or ("float4" in types_to_disable) disable_optional_type = "optional" in types_to_disable disable_sparse_tensors = "sparsetensor" in types_to_disable + disable_string_type = "string" in types_to_disable if is_windows(): cmake_args += [ "-Donnxruntime_USE_DML=" + ("ON" if args.use_dml else "OFF"), @@ -513,6 +514,7 @@ def generate_build_tree( "-Donnxruntime_DISABLE_FLOAT4_TYPES=" + ("ON" if disable_float4_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"), + "-Donnxruntime_DISABLE_STRING_TYPE=" + ("ON" if disable_string_type else "OFF"), "-Donnxruntime_CUDA_MINIMAL=" + ("ON" if args.enable_cuda_minimal_build else "OFF"), ] if args.minimal_build is not None: diff --git a/tools/ci_build/build_args.py b/tools/ci_build/build_args.py index f32666f65cc38..79e22f0fc3357 100644 --- a/tools/ci_build/build_args.py +++ b/tools/ci_build/build_args.py @@ -551,7 +551,7 @@ def add_size_reduction_args(parser: argparse.ArgumentParser) -> None: "--disable_types", nargs="+", default=[], - choices=["float4", "float8", "optional", "sparsetensor"], + choices=["float4", "float8", "optional", "sparsetensor", "string"], help="Disable selected data types.", ) parser.add_argument(