Skip to content

request Ort::InitApi() be noexcept #12581

@diablodale

Description

@diablodale

In ORT v1.12.0 the Ort::InitApi() is not defined noexcept.

I request it be noexcept so that it can be used easily in all code blocks including default constructors (which should be themselves noexcept and therefore cascades down).

Both ORT_API_MANUAL_INIT codepaths are already exception safe today in their code

Setup

  • <package id="Microsoft.ML.OnnxRuntime.DirectML" version="1.12.0" />
  • VS2019 community v16.11.18

Recommended code

in packages\Microsoft.ML.OnnxRuntime.DirectML.1.12.0\build\native\include\onnxruntime_cxx_api.h

inline void InitApi() { Global<void>::api_ = OrtGetApiBase()->GetApi(ORT_API_VERSION); }
// to
inline void InitApi() NO_EXCEPTION { Global<void>::api_ = OrtGetApiBase()->GetApi(ORT_API_VERSION); }

Workaround

  • private build
  • try/catch wrapping

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiissues related to all other APIs: C, C++, Python, etc.feature requestrequest for unsupported feature or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions