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/vision/decode_image.hpp

53lines · 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#include <cstdint>
10
11namespace ort_extensions {
12struct KernelDecodeImage : BaseKernel {
13 KernelDecodeImage(const OrtApi& api, const OrtKernelInfo& info) : BaseKernel(api, info) {}
14
15 void Compute(OrtKernelContext* context);
16};
17
18struct CustomOpDecodeImage : OrtW::CustomOpBase<CustomOpDecodeImage, KernelDecodeImage> {
19 void KernelDestroy(void* op_kernel) {
20 delete static_cast<KernelDecodeImage*>(op_kernel);
21 }
22
23 const char* GetName() const {
24 return "DecodeImage";
25 }
26
27 size_t GetInputTypeCount() const {
28 return 1;
29 }
30
31 ONNXTensorElementDataType GetInputType(size_t index) const {
32 switch (index) {
33 case 0:
34 return ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8;
35 default:
36 ORTX_CXX_API_THROW(MakeString("Invalid input index ", index), ORT_INVALID_ARGUMENT);
37 }
38 }
39
40 size_t GetOutputTypeCount() const {
41 return 1;
42 }
43
44 ONNXTensorElementDataType GetOutputType(size_t index) const {
45 switch (index) {
46 case 0:
47 return ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8;
48 default:
49 ORTX_CXX_API_THROW(MakeString("Invalid output index ", index), ORT_INVALID_ARGUMENT);
50 }
51 }
52};
53} // namespace ort_extensions
54