HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
rocm_context.h
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the MIT License.
3
4
#define ORT_ROCM_CTX
5
6
#include "
rocm_resource.h
"
7
#include "
core/providers/custom_op_context.h
"
8
#include <hip/hip_runtime.h>
9
#include <miopen/miopen.h>
10
#include <hipblas/hipblas.h>
11
12
namespace
Ort {
13
14
namespace
Custom
{
15
16
struct
RocmContext
:
public
CustomOpContext
{
17
hipStream_t
hip_stream
= {};
18
miopenHandle_t
miopen_handle
= {};
19
hipblasHandle_t
blas_handle
= {};
20
21
void
Init
(
const
OrtKernelContext& kernel_ctx) {
22
const
auto
& ort_api =
Ort::GetApi
();
23
void
* resource = {};
24
OrtStatus* status =
nullptr
;
25
26
status = ort_api.KernelContext_GetResource(
27
&kernel_ctx,
ORT_ROCM_RESOURCE_VERSION
,
RocmResource::hip_stream_t
, &resource);
28
if
(status) {
29
ORT_CXX_API_THROW
(
"failed to fetch hip stream"
, OrtErrorCode::ORT_RUNTIME_EXCEPTION);
30
}
31
hip_stream
=
reinterpret_cast<
hipStream_t
>
(resource);
32
33
resource = {};
34
status = ort_api.KernelContext_GetResource(
35
&kernel_ctx,
ORT_ROCM_RESOURCE_VERSION
,
RocmResource::miopen_handle_t
, &resource);
36
if
(status) {
37
ORT_CXX_API_THROW
(
"failed to fetch miopen handle"
, OrtErrorCode::ORT_RUNTIME_EXCEPTION);
38
}
39
miopen_handle
=
reinterpret_cast<
miopenHandle_t
>
(resource);
40
41
resource = {};
42
status = ort_api.KernelContext_GetResource(
43
&kernel_ctx,
ORT_ROCM_RESOURCE_VERSION
,
RocmResource::hipblas_handle_t
, &resource);
44
if
(status) {
45
ORT_CXX_API_THROW
(
"failed to fetch hipblas handle"
, OrtErrorCode::ORT_RUNTIME_EXCEPTION);
46
}
47
blas_handle
=
reinterpret_cast<
hipblasHandle_t
>
(resource);
48
}
49
};
50
51
}
// namespace Custom
52
}
// namespace Ort
Ort::Custom::RocmContext
Definition:
rocm_context.h:16
Ort::Custom::RocmContext::Init
void Init(const OrtKernelContext &kernel_ctx)
Definition:
rocm_context.h:21
hip_stream_t
Definition:
rocm_resource.h:9
Ort::Custom::RocmContext::miopen_handle
miopenHandle_t miopen_handle
Definition:
rocm_context.h:18
hipStream_t
struct ihipStream_t * hipStream_t
Definition:
oidn.h:25
Ort::GetApi
const OrtApi & GetApi() noexcept
This returns a reference to the OrtApi interface in use.
Definition:
onnxruntime_cxx_api.h:124
hipblas_handle_t
Definition:
rocm_resource.h:11
HUSD_ClipRangeMode::Custom
Use a manually-specified time code range.
miopen_handle_t
Definition:
rocm_resource.h:10
custom_op_context.h
ORT_ROCM_RESOURCE_VERSION
#define ORT_ROCM_RESOURCE_VERSION
Definition:
rocm_resource.h:6
Ort::Custom::RocmContext::blas_handle
hipblasHandle_t blas_handle
Definition:
rocm_context.h:19
rocm_resource.h
CustomOpContext
Definition:
custom_op_context.h:7
ORT_CXX_API_THROW
#define ORT_CXX_API_THROW(string, code)
Definition:
onnxruntime_cxx_api.h:77
Ort::Custom::RocmContext::hip_stream
hipStream_t hip_stream
Definition:
rocm_context.h:17
onnxruntime
core
providers
rocm
rocm_context.h
Generated on Wed Aug 27 2025 03:06:50 for HDK by
1.8.6