microsoft/onnxruntime-extensions
Publicmirrored from https://github.com/microsoft/onnxruntime-extensionsAvailable
ocos/kernels/kernels.h
27lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "ocos.h" |
| 7 | |
| 8 | typedef OrtCustomOp const* CPTR_OrtCustomOp; |
| 9 | typedef CPTR_OrtCustomOp (*FxGetSchemaInstance)(); |
| 10 | |
| 11 | FxGetSchemaInstance const* GetCustomOpSchemaList(); |
| 12 | |
| 13 | struct BaseKernel { |
| 14 | BaseKernel(OrtApi api) : api_(api), ort_(api_) { } |
| 15 | |
| 16 | protected: |
| 17 | OrtApi api_; // keep a copy of the struct, whose ref is used in the ort_ |
| 18 | Ort::CustomOpApi ort_; |
| 19 | }; |
| 20 | |
| 21 | struct OrtTensorDimensions : std::vector<int64_t> { |
| 22 | OrtTensorDimensions(Ort::CustomOpApi& ort, const OrtValue* value) { |
| 23 | OrtTensorTypeAndShapeInfo* info = ort.GetTensorTypeAndShape(value); |
| 24 | std::vector<int64_t>::operator=(ort.GetTensorShape(info)); |
| 25 | ort.ReleaseTensorTypeAndShapeInfo(info); |
| 26 | } |
| 27 | }; |
| 28 | |