Skip to content

Commit 2f67b8f

Browse files
committed
Allow configuration template to disable some SIMD.
1 parent a661140 commit 2f67b8f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

onnxruntime/core/mlas/lib/convsym.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ struct MLAS_CONV_SYM_DISPATCH {
163163

164164
#if defined(MLAS_TARGET_AMD64)
165165

166+
#if !defined(ORT_DISABLE_AVX2)
166167
const MLAS_CONV_SYM_DISPATCH MlasConvSymDispatchAvx2 = {
167168
MlasConvSymKernelAvx2,
168169
MlasConvSymDepthwiseKernelAvx2,
@@ -194,8 +195,9 @@ const MLAS_CONV_SYM_DISPATCH MlasConvSymDispatchAvxVnni = {
194195
4, // KernelDepthwiseOutputCount
195196
false, // FixupInputZeroPoint
196197
};
198+
#endif // !defined(ORT_DISABLE_AVX2)
197199

198-
#if !defined(ORT_MINIMAL_BUILD)
200+
#if !defined(ORT_MINIMAL_BUILD) && !defined(ORT_DISABLE_AVX512)
199201

200202
const MLAS_CONV_SYM_DISPATCH MlasConvSymDispatchAvx512Core = {
201203
MlasConvSymKernelAvx512Core,
@@ -229,7 +231,7 @@ const MLAS_CONV_SYM_DISPATCH MlasConvSymDispatchAvx512Vnni = {
229231
false, // FixupInputZeroPoint
230232
};
231233

232-
#endif // ORT_MINIMAL_BUILD
234+
#endif // !defined(ORT_MINIMAL_BUILD) && !defined(ORT_DISABLE_AVX512)
233235

234236
#elif defined(MLAS_TARGET_ARM64)
235237
const MLAS_CONV_SYM_DISPATCH MlasConvSymU8DispatchNeon = {

onnxruntime/core/mlas/lib/platform.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ Return Value:
289289
__cpuid(1, Cpuid1[0], Cpuid1[1], Cpuid1[2], Cpuid1[3]);
290290
#endif
291291

292-
#if defined(_MSC_VER)
292+
#if defined(_MSC_VER) && !defined(ORT_DISABLE_SSE4)
293293

294294
//
295295
// Check if the processor supports SSE 4.1 instructions.
@@ -315,6 +315,7 @@ Return Value:
315315

316316
if ((xcr0 & 0x6) == 0x6) {
317317

318+
#if !defined(ORT_DISABLE_AVX)
318319
this->GemmFloatKernel = MlasGemmFloatKernelAvx;
319320

320321
#if defined(MLAS_TARGET_AMD64)
@@ -347,6 +348,7 @@ Return Value:
347348
__cpuid_count(7, 0, Cpuid7[0], Cpuid7[1], Cpuid7[2], Cpuid7[3]);
348349
#endif
349350

351+
#if !defined(ORT_DISABLE_AVX2)
350352
if (((Cpuid1[2] & 0x1000) != 0) && ((Cpuid7[1] & 0x20) != 0)) {
351353

352354
this->GemmU8S8Dispatch = &MlasGemmU8S8DispatchAvx2;
@@ -403,6 +405,7 @@ Return Value:
403405

404406
#if !defined(ORT_MINIMAL_BUILD)
405407

408+
#if !defined(ORT_DISABLE_AVX512)
406409
//
407410
// Check if the processor supports AVX512F features and the
408411
// operating system supports saving AVX512F state.
@@ -453,8 +456,9 @@ Return Value:
453456
}
454457
}
455458
}
459+
#endif // !defined(ORT_DISABLE_AVX512)
456460

457-
#ifndef __APPLE__
461+
#if !defined(__APPLE__) && !defined(ORT_DISABLE_AMX)
458462
//
459463
// Check if the processor supports AMX-TILE and AMX-INT8
460464
// features.
@@ -467,13 +471,16 @@ Return Value:
467471
this->GemmU8S8Dispatch = &MlasGemmU8S8DispatchAmx;
468472
}
469473
}
470-
#endif // __APPLE__
474+
#endif // !defined(__APPLE__) && !defined(ORT_DISABLE_AMX)
471475

472476
#endif // ORT_MINIMAL_BUILD
473477

474478
}
479+
#endif // !defined(ORT_DISABLE_AVX2)
475480

476481
#endif // MLAS_TARGET_AMD64
482+
#endif // !defined(ORT_DISABLE_AVX)
483+
477484

478485
}
479486
}

0 commit comments

Comments
 (0)