diff --git a/hipamd/src/hip_graph.cpp b/hipamd/src/hip_graph.cpp index 8244bdb018..2dc35b1e2f 100644 --- a/hipamd/src/hip_graph.cpp +++ b/hipamd/src/hip_graph.cpp @@ -700,7 +700,9 @@ hipError_t hipStreamBeginCapture(hipStream_t stream, hipStreamCaptureMode mode) hip::Stream* s = reinterpret_cast(stream); // capture cannot be initiated on legacy stream // It can be initiated if the stream is not already in capture mode - if (stream == nullptr || s->GetCaptureStatus() == hipStreamCaptureStatusActive) { + if (stream == nullptr || + (mode < hipStreamCaptureModeGlobal || mode > hipStreamCaptureModeRelaxed) || + s->GetCaptureStatus() == hipStreamCaptureStatusActive) { HIP_RETURN(hipErrorInvalidValue); } s->SetCaptureGraph(new ihipGraph());