microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
operators/tokenizer/blingfire_sentencebreaker.hpp
35lines · 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 | #include "string_utils.h" |
| 8 | |
| 9 | extern "C" const int TextToSentencesWithOffsetsWithModel( |
| 10 | const char* pInUtf8Str, int InUtf8StrByteCount, |
| 11 | char* pOutUtf8Str, int* pStartOffsets, int* pEndOffsets, |
| 12 | const int MaxOutUtf8StrByteCount, void* hModel); |
| 13 | |
| 14 | extern "C" int FreeModel(void* ModelPtr); |
| 15 | |
| 16 | extern "C" void* SetModel(const unsigned char* pImgBytes, int ModelByteCount); |
| 17 | |
| 18 | struct KernelBlingFireSentenceBreaker : BaseKernel { |
| 19 | KernelBlingFireSentenceBreaker(OrtApi api, const OrtKernelInfo* info); |
| 20 | void Compute(OrtKernelContext* context); |
| 21 | private: |
| 22 | using ModelPtr = std::shared_ptr<void>; |
| 23 | ModelPtr model_; |
| 24 | std::string model_data_; |
| 25 | int max_sentence; |
| 26 | }; |
| 27 | |
| 28 | struct CustomOpBlingFireSentenceBreaker : Ort::CustomOpBase<CustomOpBlingFireSentenceBreaker, KernelBlingFireSentenceBreaker> { |
| 29 | void* CreateKernel(OrtApi api, const OrtKernelInfo* info) const; |
| 30 | const char* GetName() const; |
| 31 | size_t GetInputTypeCount() const; |
| 32 | ONNXTensorElementDataType GetInputType(size_t index) const; |
| 33 | size_t GetOutputTypeCount() const; |
| 34 | ONNXTensorElementDataType GetOutputType(size_t index) const; |
| 35 | }; |
| 36 | |