Skip to content

Commit

Permalink
Call nvjpegJpegStateDestroy when bailing out
Browse files Browse the repository at this point in the history
  • Loading branch information
jamt9000 committed Jan 23, 2021
1 parent a07f53a commit e485656
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions torchvision/csrc/io/image/cuda/readjpeg_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ torch::Tensor decodeJPEG_cuda(const torch::Tensor& data, ImageReadMode mode) {
outputFormat = NVJPEG_OUTPUT_RGB;
outputComponents = 3;
} else {
nvjpegJpegStateDestroy(nvjpeg_state);
TORCH_CHECK(
false, "The provided mode is not supported for JPEG files on GPU");
}
Expand All @@ -108,6 +109,7 @@ torch::Tensor decodeJPEG_cuda(const torch::Tensor& data, ImageReadMode mode) {
break;
default:
// CMYK as input might work with nvjpegDecodeParamsSetAllowCMYK()
nvjpegJpegStateDestroy(nvjpeg_state);
TORCH_CHECK(
false, "The provided mode is not supported for JPEG files on GPU");
}
Expand Down

0 comments on commit e485656

Please sign in to comment.