From 734ae398eeebfff2f2c4996d660725d63dffe59e Mon Sep 17 00:00:00 2001 From: "Tang, Cheng" Date: Wed, 18 Jan 2023 09:00:44 -0800 Subject: [PATCH] Fix a security warning in cuda gemm int8 kernel (#14335) ### Description fix a security warning in GemmInt8 cuda kernel ### Motivation and Context it is for issue: https://dev.azure.com/aiinfra/ONNX%20Runtime/_workitems/edit/11158/ Co-authored-by: Cheng Tang --- onnxruntime/core/providers/cuda/integer_gemm.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/onnxruntime/core/providers/cuda/integer_gemm.cc b/onnxruntime/core/providers/cuda/integer_gemm.cc index 76bc708736..9c2a05e9a9 100644 --- a/onnxruntime/core/providers/cuda/integer_gemm.cc +++ b/onnxruntime/core/providers/cuda/integer_gemm.cc @@ -20,8 +20,9 @@ Status GemmInt8(int m, int n, int k, const CudaKernel* cuda_kernel, onnxruntime::Stream* ort_stream) { ORT_ENFORCE(a != nullptr && b != nullptr && c != nullptr, "input matrix should not be null"); ORT_ENFORCE(cuda_kernel != nullptr, "kernel is null"); + ORT_ENFORCE(ort_stream != nullptr, "Cuda kernel must have the stream instance"); - cudaStream_t stream = ort_stream ? static_cast(ort_stream->GetHandle()) : nullptr; + cudaStream_t stream = static_cast(ort_stream->GetHandle()); // pad A and B to make their leading dimension be multiples of 32 // because cublasGemmEx requires: