microsoft/onnxruntime-extensions

Public

mirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
9eef22cb81d762f6c093a4740c992582267a783f

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

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
9extern "C" const int TextToSentencesWithOffsetsWithModel(
10 const char* pInUtf8Str, int InUtf8StrByteCount,
11 char* pOutUtf8Str, int* pStartOffsets, int* pEndOffsets,
12 const int MaxOutUtf8StrByteCount, void* hModel);
13
14extern "C" int FreeModel(void* ModelPtr);
15
16extern "C" void* SetModel(const unsigned char* pImgBytes, int ModelByteCount);
17
18struct 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
28struct 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