From cfe31f1913f0628dcbbdbfb85bba18a252a58e2b Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Mon, 29 Jul 2024 14:35:17 +0900 Subject: [PATCH] [onert] Set dilation factor in DepthwiseConv train kernel This commit sets dilation factor in DepthwiseConv train kernel. The DepthwiseConv train kernel does not support dilation value other than 1. It adds assertion to check the supported dilation value. ONE-DCO-1.0-Signed-off-by: Jiyoung Yun --- compute/cker/include/cker/train/operation/DepthwiseConv.h | 6 ++++++ .../onert/backend/train/ops/DepthwiseConvolutionLayer.cc | 2 ++ 2 files changed, 8 insertions(+) diff --git a/compute/cker/include/cker/train/operation/DepthwiseConv.h b/compute/cker/include/cker/train/operation/DepthwiseConv.h index b9fab257bd3..b56987c7fff 100644 --- a/compute/cker/include/cker/train/operation/DepthwiseConv.h +++ b/compute/cker/include/cker/train/operation/DepthwiseConv.h @@ -56,6 +56,9 @@ class DepthwiseConv if (params.stride_height != params.stride_width) throw std::runtime_error("Not support different length strides"); + if (params.dilation_height_factor != 1 || params.dilation_width_factor != 1) + throw std::runtime_error{"Not support dilation other than 1."}; + const int batch = MatchingDim(incoming_shape, 0, grad_shape, 0); const int input_depth = grad_shape.Dims(3); const int output_depth = incoming_shape.Dims(3); @@ -86,6 +89,9 @@ class DepthwiseConv if (params.stride_height != params.stride_width) throw std::runtime_error("Not support different length strides"); + if (params.dilation_height_factor != 1 || params.dilation_width_factor != 1) + throw std::runtime_error{"Not support dilation other than 1."}; + const int batch = MatchingDim(incoming_shape, 0, input_shape, 0); const int input_depth = input_shape.Dims(3); const int output_depth = incoming_shape.Dims(3); diff --git a/runtime/onert/backend/train/ops/DepthwiseConvolutionLayer.cc b/runtime/onert/backend/train/ops/DepthwiseConvolutionLayer.cc index f4c14e2bc8c..d62c37ad3cc 100644 --- a/runtime/onert/backend/train/ops/DepthwiseConvolutionLayer.cc +++ b/runtime/onert/backend/train/ops/DepthwiseConvolutionLayer.cc @@ -147,6 +147,8 @@ void DepthwiseConvolutionLayer::backwardFloat32() dconv_params.padding_values.width = _paddingLeft; dconv_params.padding_values.height = _paddingTop; dconv_params.depth_multiplier = _multiplier; + dconv_params.dilation_height_factor = _dilationHeight; + dconv_params.dilation_width_factor = _dilationWidth; // Calculate gradient for input _dconv_kernel->backpropInput(