microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
13d9e27ccd8a0de9a1225756fbf6860a1931484f

Branches

Tags

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

Clone

HTTPS

Download ZIP

operators/text/op_ragged_tensor.hpp

60lines · 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)
10 : BaseKernel(api) {}
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 void* CreateKernel(const OrtApi& api, const OrtKernelInfo* /* info */) const;
45 ONNXTensorElementDataType GetInputType(size_t index) const;
46};
47
48struct KernelStringRaggedTensorToDense : CommonRaggedTensorToDense {
49 KernelStringRaggedTensorToDense(const OrtApi& api, const OrtKernelInfo* info);
50 void Compute(OrtKernelContext* context);
51};
52
53struct CustomOpStringRaggedTensorToDense : OrtW::CustomOpBase<CustomOpStringRaggedTensorToDense, KernelStringRaggedTensorToDense> {
54 size_t GetInputTypeCount() const;
55 size_t GetOutputTypeCount() const;
56 ONNXTensorElementDataType GetOutputType(size_t index) const;
57 const char* GetName() const;
58 void* CreateKernel(const OrtApi& api, const OrtKernelInfo* /* info */) const;
59 ONNXTensorElementDataType GetInputType(size_t index) const;
60};
61