mirror of
https://github.com/open-mmlab/mmdeploy.git
synced 2025-01-14 08:09:43 +08:00
* Update custom ops namespace * rename register, rename generated library name * rename domain to mmcv
33 lines
798 B
C++
33 lines
798 B
C++
#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
|