Skip to content

Commit 1087d73

Browse files
snnnJonathanC-ARM
authored andcommitted
Refactor: Move fundamental data type headers to core/common (microsoft#26330)
Move `endian.h`, `float16.h`, and `float8.h` from `core/framework/` to `core/common/` to avoid circular dependencies and improve architectural layering. ## Motivation These headers define fundamental data types that are used across multiple low-level libraries: - `onnxruntime_common` (foundation layer) - `onnxruntime_mlas` (math library, depends on common) - `onnxruntime_util` (utilities, depends on common) - `onnxruntime_graph` (graph IR, depends on common) Previously, these types were in `core/framework/`, which is part of the `onnxruntime_framework` library that sits at a higher architectural level. This created circular dependency issues since mlas uses the "float16.h" . ## Changes ### File Moves (3 files): - `include/onnxruntime/core/framework/endian.h` → `include/onnxruntime/core/common/endian.h` - `include/onnxruntime/core/framework/float16.h` → `include/onnxruntime/core/common/float16.h` - `include/onnxruntime/core/framework/float8.h` → `include/onnxruntime/core/common/float8.h` ### Include Path Updates (53 files): Updated all references from: - `core/framework/endian.h` → `core/common/endian.h` - `core/framework/float16.h` → `core/common/float16.h` - `core/framework/float8.h` → `core/common/float8.h` Affected components: - Contrib ops (CPU, CUDA, ROCm) - Core framework and utilities - Providers (CPU, CUDA, CANN, QNN, OpenVINO, MIGraphX) - Tests - Training code ## Architectural Benefits This change establishes clearer architectural boundaries: ``` Level 0 (Foundation): onnxruntime_common (includes endian, float16, float8) onnxruntime_mlas → depends on common Level 1 (Core): onnxruntime_util → depends on common onnxruntime_graph → depends on common Level 2 (Framework): onnxruntime_framework → depends on common ``` By placing fundamental types in `common`, we ensure: 1. No circular dependencies between library targets 2. Lower-level libraries can access these types without pulling in framework 3. Clear separation between fundamental types (common) and framework-specific types like int4, float4 (framework) This PR is split from microsoft#26317 as suggested by the reviewer.
1 parent 3891c2a commit 1087d73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+65
-65
lines changed

include/onnxruntime/core/framework/float16.h renamed to include/onnxruntime/core/common/float16.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
#include <math.h>
66

7-
#include "endian.h"
7+
#include "core/common/endian.h"
88
#if defined(CUDA_VERSION) && CUDA_VERSION >= 11000
9-
#include "cuda_bf16.h"
9+
#include "cuda_bf16.h" // from CUDA SDK
1010
#endif
1111

1212
#if !defined(__CUDACC__) && !defined(__HIPCC__)

include/onnxruntime/core/framework/float8.h renamed to include/onnxruntime/core/common/float8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#if !defined(DISABLE_FLOAT8_TYPES)
1818

19-
#include "endian.h"
19+
#include "core/common/endian.h"
2020

2121
#if defined(__CUDACC__)
2222
// Needed for CUDA_VERSION check below

include/onnxruntime/core/framework/data_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include <gsl/gsl>
1313
#include "core/common/common.h"
1414
#include "core/common/exceptions.h"
15-
#include "core/framework/endian.h"
16-
#include "core/framework/float8.h"
17-
#include "core/framework/float16.h"
15+
#include "core/common/endian.h"
16+
#include "core/common/float8.h"
17+
#include "core/common/float16.h"
1818
#include "core/framework/int4.h"
1919
#include "core/framework/float4.h"
2020
#include "core/graph/onnx_protobuf.h"

include/onnxruntime/core/framework/to_tensor_proto_element_type.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#endif
1212

1313
#include "core/framework/float4.h"
14-
#include "core/framework/float8.h"
15-
#include "core/framework/float16.h"
14+
#include "core/common/float8.h"
15+
#include "core/common/float16.h"
1616
#include "core/framework/int4.h"
1717

1818
namespace onnxruntime {

onnxruntime/contrib_ops/cpu/moe/moe_cpu.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "core/providers/cpu/math/gemm_helper.h"
1010
#include "core/util/math_cpuonly.h"
1111
#include "core/mlas/inc/mlas.h"
12-
#include "core/framework/float16.h"
12+
#include "core/common/float16.h"
1313
#include "core/framework/allocator.h"
1414
#include "core/platform/threadpool.h"
1515
#include "core/common/narrow.h"

onnxruntime/contrib_ops/cpu/moe/moe_quantization_cpu.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "contrib_ops/cpu/moe/moe_quantization_cpu.h"
55
#include "core/framework/allocator.h"
6-
#include "core/framework/float16.h"
6+
#include "core/common/float16.h"
77
#include "core/mlas/inc/mlas.h"
88
#include "core/mlas/inc/mlas_q4.h"
99
#include "core/platform/threadpool.h"

onnxruntime/contrib_ops/cpu/quantization/dequantize_blockwise_bnb4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <vector>
99

1010
#include "core/common/safeint.h"
11-
#include "core/framework/float16.h"
11+
#include "core/common/float16.h"
1212
#include "core/platform/threadpool.h"
1313
#include <iostream>
1414

onnxruntime/contrib_ops/cpu/quantization/gather_block_quantized.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "core/common/common.h"
88
#include "core/common/narrow.h"
99
#include "core/common/safeint.h"
10-
#include "core/framework/float16.h"
10+
#include "core/common/float16.h"
1111
#include "core/framework/int4.h"
1212
#include "core/framework/op_kernel.h"
1313
#include "core/platform/threadpool.h"

onnxruntime/contrib_ops/cpu/quantization/matmul_nbits_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <type_traits>
1010

1111
#include "core/common/common.h"
12-
#include "core/framework/float16.h"
12+
#include "core/common/float16.h"
1313
#include "core/providers/common.h"
1414
#include "core/platform/threadpool.h"
1515

0 commit comments

Comments
 (0)