34 lines
847 B
C
Raw Normal View History

2021-11-30 15:00:37 +08:00
// Copyright (c) OpenMMLab. All rights reserved.
#ifndef ORT_MMCV_UTILS_H
#define ORT_MMCV_UTILS_H
#include <onnxruntime_cxx_api.h>
#include <vector>
namespace mmdeploy {
struct OrtTensorDimensions : std::vector<int64_t> {
OrtTensorDimensions(Ort::CustomOpApi ort, const OrtValue* value) {
OrtTensorTypeAndShapeInfo* info = ort.GetTensorTypeAndShape(value);
std::vector<int64_t>::operator=(ort.GetTensorShape(info));
ort.ReleaseTensorTypeAndShapeInfo(info);
}
};
std::vector<OrtCustomOp*>& get_mmdeploy_custom_ops();
template <typename T>
class OrtOpsRegistrar {
public:
OrtOpsRegistrar() { get_mmdeploy_custom_ops().push_back(&instance); }
private:
T instance{};
};
#define REGISTER_ONNXRUNTIME_OPS(name) \
static OrtOpsRegistrar<name> OrtOpsRegistrar##name {}
} // namespace mmdeploy
#endif // ORT_MMCV_UTILS_H