Files
pytorch/caffe2/onnx/onnxifi_init.cc
Kimish Patel e58cc6ab28 Enable single graph sharing between multiple threads for onnxifiop (#16047)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16047

Implements single thead safe map enabling sharing of generated graph between
different ops.
Added model_id to every onnxified op to help create a unique id in the map.
Some formatting fix.

Reviewed By: yinghai

Differential Revision: D13663927

fbshipit-source-id: 27417e8fe752fdd48abb6a87966cd76d592e1206
2019-01-16 12:19:16 -08:00

23 lines
473 B
C++

#include "caffe2/onnx/onnxifi_init.h"
#include <mutex>
#include "caffe2/core/logging.h"
namespace caffe2 {
namespace onnx {
onnxifi_library* initOnnxifiLibrary() {
static std::once_flag once;
static onnxifi_library core{};
std::call_once(once, []() {
auto ret = onnxifi_load(ONNXIFI_LOADER_FLAG_VERSION_1_0, nullptr, &core);
if (!ret) {
CAFFE_THROW("Cannot load onnxifi lib");
}
});
return &core;
}
} // namespace onnx
} // namespace caffe2