diff --git a/include/onnxruntime/core/providers/cuda/cuda_resource.h b/include/onnxruntime/core/providers/cuda/cuda_resource.h index bc6c4080682bf..e46fc5b4219dd 100644 --- a/include/onnxruntime/core/providers/cuda/cuda_resource.h +++ b/include/onnxruntime/core/providers/cuda/cuda_resource.h @@ -9,4 +9,4 @@ enum CudaResource : int { cuda_stream_t = cuda_resource_offset, cudnn_handle_t, cublas_handle_t -}; +}; \ No newline at end of file diff --git a/include/onnxruntime/core/providers/dml/dml_resource.h b/include/onnxruntime/core/providers/dml/dml_resource.h index 6ee67f5ba9977..1713570a42a60 100644 --- a/include/onnxruntime/core/providers/dml/dml_resource.h +++ b/include/onnxruntime/core/providers/dml/dml_resource.h @@ -10,4 +10,4 @@ enum DmlResource : int { d3d12_device_t, cmd_list_t, cmd_recorder_t -}; +}; \ No newline at end of file diff --git a/include/onnxruntime/core/providers/rocm/rocm_resource.h b/include/onnxruntime/core/providers/rocm/rocm_resource.h index 70309ac363744..53f26c13e93e0 100644 --- a/include/onnxruntime/core/providers/rocm/rocm_resource.h +++ b/include/onnxruntime/core/providers/rocm/rocm_resource.h @@ -10,4 +10,3 @@ enum RocmResource : int { miopen_handle_t, rocblas_handle_t }; - diff --git a/onnxruntime/core/session/custom_ops.cc b/onnxruntime/core/session/custom_ops.cc index 113473994db3c..14c284d7bbdec 100644 --- a/onnxruntime/core/session/custom_ops.cc +++ b/onnxruntime/core/session/custom_ops.cc @@ -135,6 +135,9 @@ ORT_API_STATUS_IMPL(OrtApis::KernelContext_GetResource, _In_ const OrtKernelCont *resource = {}; const auto* ctx = reinterpret_cast(context); auto* stream = reinterpret_cast(ctx->GetComputeStream()); + if (!stream) { + return OrtApis::CreateStatus(ORT_INVALID_ARGUMENT, "Failed to fetch a stream hosting the requested resource"); + } *resource = stream->GetResource(resource_version, resource_id); if (!(*resource)) { return OrtApis::CreateStatus(ORT_INVALID_ARGUMENT, "Requested resource does not exist");