microsoft/onnxruntime-extensions

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.14.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

include/custom_op/kernel_context.h

38lines · modeblame

97ee9eb5Wenbing Li2 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
64646279Wenbing Li2 years ago4#pragma once
5#include <optional>
6#include <numeric>
7#include <type_traits>
8
9namespace Ort {
10namespace Custom {
11
12// this is for the ORT custom op template magic
13struct Arg {
14virtual ~Arg() = default;
15};
16
17class KernelContext : public Arg{
18public:
19virtual void* AllocScratchBuffer(size_t size) = 0;
20virtual void FreeScratchBuffer(void* p) = 0;
21// TODO: threadpool?
22};
23
24#ifdef USE_CUDA
25class CUDAKernelContext : public KernelContext {
26public:
27virtual void* AllocCudaScratchBuffer(size_t size) = 0;
28virtual void FreeCudaScratchBuffer(void* p) = 0;
29virtual void* GetCudaStream() const = 0;
30virtual void* GetCublasHandle() const = 0;
31virtual int GetCudaDeviceId() const = 0;
32};
33#endif
34
35// TODO: helper func to create context from global ORT env.
36
37}
38}