calibration_profile_store.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 runtime

Typedefs

using CalibrationPolicySerializer = std::function<std::string()>#

Serializes a backend-owned policy payload.

using CalibrationPolicyValidator = std::function<bool(std::string_view, std::string&)>#

Validates or deserializes a serialized backend policy.

Returns true for an accepted payload and writes a rejection explanation to the second argument otherwise.

Enums

enum class CalibrationProfileKind#

Identifies whether a calibration profile is machine-specific or portable.

Values:

enumerator kExact#
enumerator kPortable#
enum class CalibrationProfileStoreStatus#

Classifies profile loading and mutation results.

Values:

enumerator kOk#
enumerator kNotFound#
enumerator kDisabled#
enumerator kUnreadable#
enumerator kMalformed#
enumerator kUnsupportedVersion#
enumerator kPolicyRejected#
enumerator kWriteFailed#
enum class CalibrationProfileRejectionReason#

Explains why a stored profile was not selected.

Values:

enumerator kDifferentBackend#
enumerator kDifferentOperator#
enumerator kOutdatedImplementation#
enumerator kDifferentModel#
enumerator kDifferentProcessor#
enumerator kDifferentThreadCount#
enumerator kDifferentStructure#
enumerator kPolicyRejected#
struct CalibrationMeasurement#
#include <calibration_profile_store.h>

Stores one named calibration measurement.

Public Functions

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

Public Members

std::string name#
double value = 0#
std::string unit#
struct CalibrationProfile#
#include <calibration_profile_store.h>

Stores a serialized backend policy and the measurements used to select it.

policy is opaque to onnx-light. Backends serialize and validate it through callbacks passed to :cpp:class:CalibrationProfileStore.

Public Functions

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

Public Members

CalibrationProfileKey key#
std::string policy#
std::vector<CalibrationMeasurement> measurements#
bool user_override = false#
struct CalibrationProfileKey#
#include <calibration_profile_store.h>

Identifies a backend calibration profile.

Exact profiles use model_digest, processor, and thread_count. Portable profiles instead use structural_properties.

Public Functions

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

Public Members

std::string backend#
std::string operator_name#
std::string implementation_version#
CalibrationProfileKind kind = CalibrationProfileKind::kExact#
std::string model_digest#
std::string processor#
uint32_t thread_count = 0#
std::map<std::string, std::string> structural_properties#
struct CalibrationProfileLookupOptions#
#include <calibration_profile_store.h>

Controls exact/portable profile resolution.

Public Members

CalibrationProfileKey exact_key#
std::map<std::string, std::string> structural_properties#
bool force_portable = false#
struct CalibrationProfileLookupReport#
#include <calibration_profile_store.h>

Reports profile selection and every rejected candidate.

Public Members

CalibrationProfileStoreStatus status = CalibrationProfileStoreStatus::kNotFound#
std::optional<CalibrationProfile> profile#
std::vector<CalibrationProfileRejection> rejections#
std::vector<std::string> diagnostics#
struct CalibrationProfileRejection#
#include <calibration_profile_store.h>

Reports one rejected candidate.

Public Members

CalibrationProfileKey key#
CalibrationProfileRejectionReason reason#
std::string message#
class CalibrationProfileStore#
#include <calibration_profile_store.h>

Stores backend calibration profiles in memory and, optionally, on disk.

Mutations are synchronized between threads and processes. Persistent updates merge the latest disk contents and atomically replace the store file.

Public Functions

explicit CalibrationProfileStore(CalibrationProfileStoreOptions options = {})#
CalibrationProfileStoreReport Reload()#

Reloads profiles from persistent storage.

Existing in-memory profiles remain unchanged when the file is malformed, incompatible, or unreadable.

CalibrationProfileStoreReport Store(const CalibrationProfileKey &key, std::vector<CalibrationMeasurement> measurements, const CalibrationPolicySerializer &serialize, const CalibrationPolicyValidator &validate = {})#

Stores calibration results after backend serialization and validation.

The serializer is invoked exactly once. A rejected payload is not stored.

CalibrationProfileLookupReport Lookup(const CalibrationProfileLookupOptions &options, const CalibrationPolicyValidator &validate = {}) const#

Resolves an override, exact profile, or portable profile in that order.

CalibrationProfileStoreReport InstallOverride(const CalibrationProfileKey &key, const CalibrationPolicySerializer &serialize, const CalibrationPolicyValidator &validate = {})#

Installs and persists an explicit user override.

CalibrationProfileStoreReport ClearOverride(const CalibrationProfileKey &key)#

Clears matching user overrides.

CalibrationProfileStoreReport Invalidate(std::string_view backend, std::optional<std::string_view> implementation_version = std::nullopt)#

Invalidates profiles for a backend and, optionally, one implementation version.

An absent version invalidates every version owned by the backend.

std::vector<CalibrationProfile> Inspect() const#

Returns a snapshot of every in-memory profile.

inline bool persistence_enabled() const noexcept#

Returns whether persistent reads and writes are enabled.

inline const std::filesystem::path &path() const noexcept#

Returns the configured or default persistent path.

Public Static Functions

static std::filesystem::path DefaultPath()#

Returns the platform-specific default calibration profile path.

Private Functions

CalibrationProfileStoreReport Mutate(const std::function<size_t(std::vector<CalibrationProfile>&)>&)#

Private Members

CalibrationProfileStoreOptions options_#
std::filesystem::path path_#
mutable std::mutex mutex_#
std::vector<CalibrationProfile> profiles_#
struct CalibrationProfileStoreOptions#
#include <calibration_profile_store.h>

Controls persistent storage.

Public Members

std::filesystem::path path#
bool persistence_enabled = true#
struct CalibrationProfileStoreReport#
#include <calibration_profile_store.h>

Reports loading or mutation of the profile store.

Public Members

CalibrationProfileStoreStatus status = CalibrationProfileStoreStatus::kOk#
size_t affected_profiles = 0#
std::vector<std::string> diagnostics#