From fc760de348ba545ed1ee049ed4d5504f25d89f09 Mon Sep 17 00:00:00 2001 From: raver119 Date: Tue, 24 Dec 2019 18:45:54 +0300 Subject: [PATCH] RgbToYuv & YuvToRgb skip empty arrays Signed-off-by: raver119 --- libnd4j/include/ops/declarable/generic/images/rgbToYuv.cpp | 4 ++++ libnd4j/include/ops/declarable/generic/images/yuvToRgb.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libnd4j/include/ops/declarable/generic/images/rgbToYuv.cpp b/libnd4j/include/ops/declarable/generic/images/rgbToYuv.cpp index 42640aff3..58dd8a432 100644 --- a/libnd4j/include/ops/declarable/generic/images/rgbToYuv.cpp +++ b/libnd4j/include/ops/declarable/generic/images/rgbToYuv.cpp @@ -33,6 +33,10 @@ CONFIGURABLE_OP_IMPL(rgb_to_yuv, 1, 1, true, 0, 0) { auto input = INPUT_VARIABLE(0); auto output = OUTPUT_VARIABLE(0); + // just skip op if input is empty + if (input->isEmpty()) + return Status::OK(); + const int rank = input->rankOf(); const int argSize = block.getIArguments()->size(); const int dimC = argSize > 0 ? (INT_ARG(0) >= 0 ? INT_ARG(0) : INT_ARG(0) + rank) : rank - 1; diff --git a/libnd4j/include/ops/declarable/generic/images/yuvToRgb.cpp b/libnd4j/include/ops/declarable/generic/images/yuvToRgb.cpp index f238e0694..90ca217ce 100644 --- a/libnd4j/include/ops/declarable/generic/images/yuvToRgb.cpp +++ b/libnd4j/include/ops/declarable/generic/images/yuvToRgb.cpp @@ -31,6 +31,10 @@ CONFIGURABLE_OP_IMPL(yuv_to_rgb, 1, 1, true, 0, 0) { auto input = INPUT_VARIABLE(0); auto output = OUTPUT_VARIABLE(0); + // just skip op if input is empty + if (input->isEmpty()) + return Status::OK(); + const int rank = input->rankOf(); const int argSize = block.getIArguments()->size(); const int dimC = argSize > 0 ? (INT_ARG(0) >= 0 ? INT_ARG(0) : INT_ARG(0) + rank) : rank - 1;