Source code for experimental_experiment.convert.ort_helper
importosfromonnximportModelProto
[docs]defappend_custom_libraries(onx:ModelProto,options:"onnxruntime.SessionOptions",# noqa: F821):""" Appends libraries implementing custom kernels. The functions checks the opsets then add the necessary custom libraries to the options. :param onx: model proto :param options: onnxruntime.SessionOptions """domains=set(d.domainfordinonx.opset_import)if"onnx_extended.ortops.optim.cuda"indomains:fromonnx_extended.ortops.optim.cudaimportget_ort_ext_libsassertos.path.exists(get_ort_ext_libs()[0]),f"Unable to find library {get_ort_ext_libs()[0]!r}."options.register_custom_ops_library(get_ort_ext_libs()[0])elif"onnx_extended.ortops.optim.cpu"indomains:fromonnx_extended.ortops.optim.cpuimportget_ort_ext_libsassertos.path.exists(get_ort_ext_libs()[0]),f"Unable to find library {get_ort_ext_libs()[0]!r}."options.register_custom_ops_library(get_ort_ext_libs()[0])