microsoft/onnxruntime-extensions

Public

mirrored from https://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.7.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

operators/text/op_ragged_tensor.hpp

59lines · 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
8struct KernelRaggedTensorToSparse : BaseKernel {
9 KernelRaggedTensorToSparse(const OrtApi& api, const OrtKernelInfo& info)
10 : BaseKernel(api, info) {}
11
12 void Compute(OrtKernelContext* context);
13};
14
15struct CustomOpRaggedTensorToSparse : OrtW::CustomOpBase<CustomOpRaggedTensorToSparse, KernelRaggedTensorToSparse> {
16 size_t GetInputTypeCount() const;
17 size_t GetOutputTypeCount() const;
18 ONNXTensorElementDataType GetOutputType(size_t index) const;
19 const char* GetName() const;
20 ONNXTensorElementDataType GetInputType(size_t index) const;
21};
22
23struct CommonRaggedTensorToDense : BaseKernel {
24 CommonRaggedTensorToDense(const OrtApi& api, const OrtKernelInfo& info);
25
26 protected:
27 void GetInputDims(OrtKernelContext* context, const OrtValue** inputs, OrtTensorDimensions* dims);
28 int64_t GetMaxCol(int64_t n, const int64_t* p_indices);
29};
30
31struct KernelRaggedTensorToDense : CommonRaggedTensorToDense {
32 KernelRaggedTensorToDense(const OrtApi& api, const OrtKernelInfo& info);
33 void Compute(OrtKernelContext* context);
34
35 private:
36 int64_t missing_value_;
37};
38
39struct CustomOpRaggedTensorToDense : OrtW::CustomOpBase<CustomOpRaggedTensorToDense, KernelRaggedTensorToDense> {
40 size_t GetInputTypeCount() const;
41 size_t GetOutputTypeCount() const;
42 ONNXTensorElementDataType GetOutputType(size_t index) const;
43 const char* GetName() const;
44 ONNXTensorElementDataType GetInputType(size_t index) const;
45};
46
47struct KernelStringRaggedTensorToDense : CommonRaggedTensorToDense {
48 KernelStringRaggedTensorToDense(const OrtApi& api, const OrtKernelInfo& info);
49 void Compute(OrtKernelContext* context);
50};
51
52struct CustomOpStringRaggedTensorToDense : OrtW::CustomOpBase<CustomOpStringRaggedTensorToDense,
53 KernelStringRaggedTensorToDense> {
54 size_t GetInputTypeCount() const;
55 size_t GetOutputTypeCount() const;
56 ONNXTensorElementDataType GetOutputType(size_t index) const;
57 const char* GetName() const;
58 ONNXTensorElementDataType GetInputType(size_t index) const;
59};
60