microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
3e82549bcb53bc93d04c25d64f16a52d495725c1

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