cpu_descriptor.h#

namespace onnx_light

Alias that makes onnx-light headers compatible with code that references ONNX_LIGHT_NAMESPACE (the macro used in the standard onnx package).

Set to ONNX_LIGHT_NAMESPACE so both names resolve to the same namespace.

Symbol-visibility attribute for the public onnx-light C++ API.

Maps the upstream compatibility macro to onnx-light’s explicit proto ABI annotation. This keeps declarations from vendored ONNX headers visible when lib_onnx_proto uses hidden visibility by default.

Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal onnx namespace — rather than the ONNX_NAMESPACE macro — resolves to the onnx-light namespace. The standard onnx package lives in namespace onnx; onnx-light uses onnx_light (via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs from onnx.

namespace core
namespace platform#

Enums

enum class CpuFeature : uint8_t#

Identifies an instruction-set capability usable by the current process.

The numeric values are stable to keep CpuFeatureSet::bits() and CpuFeatureName serialization stable across releases.

Values:

enumerator kSse2#
enumerator kSse41#
enumerator kSse42#
enumerator kAvx#
enumerator kFma#
enumerator kAvx2#
enumerator kAvx512F#
enumerator kAvx512Bw#
enumerator kAvx512Vl#
enumerator kNeon#
enumerator kDotProduct#
enumerator kSve#
enumerator kSve2#

Functions

std::string_view CpuFeatureName(CpuFeature feature) noexcept#

Returns the stable serialized name of a CPU feature.

Returns: The lowercase feature name.

std::optional<CpuFeature> CpuFeatureFromName(std::string_view name) noexcept#

Parses a stable CPU feature name.

Returns: The feature, or std::nullopt for an unknown name.

CpuDescriptor DetectCpuDescriptor()#

Detects processor properties visible to the current process.

Returns: A descriptor whose unavailable fields remain unknown.

const CpuDescriptor &GetCpuDescriptor()#

Returns the processor descriptor detected once for the current process.

Returns: The immutable process-wide descriptor.

struct CpuDescriptor#
#include <cpu_descriptor.h>

Describes immutable properties of the processor visible to the process.

Optional values remain absent when the operating system or architecture cannot report them reliably.

Public Functions

bool operator==(const CpuDescriptor&) const = default#

Public Members

std::string architecture#
std::string vendor#
std::optional<uint32_t> family#
std::optional<uint32_t> model#
std::optional<uint32_t> stepping#
std::string microarchitecture#
CpuFeatureSet features#
std::optional<size_t> cache_line_bytes#
std::optional<size_t> l1_data_bytes#
std::optional<size_t> l2_bytes#
std::optional<size_t> l3_bytes#
std::optional<uint32_t> physical_cores#
std::optional<uint32_t> logical_cores#
class CpuFeatureSet#
#include <cpu_descriptor.h>

Stores a compact set of CPU instruction-set capabilities.

Public Functions

constexpr CpuFeatureSet() = default#
inline explicit constexpr CpuFeatureSet(uint64_t bits)#
inline constexpr void Add(CpuFeature feature)#

Adds a feature to the set.

inline constexpr bool Has(CpuFeature feature) const#

Returns whether the set contains a feature.

Returns: true when the feature is present.

inline constexpr bool ContainsAll(CpuFeatureSet other) const#

Returns whether every feature in another set is present.

Returns: true when all requested features are present.

inline constexpr bool Intersects(CpuFeatureSet other) const#

Returns whether this set and another set share a feature.

Returns: true when at least one feature is shared.

inline constexpr uint64_t bits() const#

Returns the underlying stable bit mask.

constexpr bool operator==(const CpuFeatureSet&) const = default#

Private Members

uint64_t bits_ = 0#

Private Static Functions

static inline constexpr uint64_t FeatureBit(CpuFeature feature)#
struct CpuSelector#
#include <cpu_descriptor.h>

Selects processors using stable identifiers rather than display names.

Empty optional fields and an empty model list are wildcards. Thread limits require an explicit effective thread count when matching.

Public Functions

bool Matches(const CpuDescriptor &processor, std::optional<uint32_t> effective_threads = std::nullopt) const#

Returns whether a processor and execution thread count satisfy the selector.

Returns: true when every specified criterion matches.

Public Members

std::optional<std::string> architecture#
std::optional<std::string> vendor#
std::optional<uint32_t> family#
std::vector<uint32_t> models#
std::optional<std::string> microarchitecture#
CpuFeatureSet required_features#
CpuFeatureSet excluded_features#
std::optional<uint32_t> minimum_threads#
std::optional<uint32_t> maximum_threads#