diff --git a/mace/core/operator.cc b/mace/core/operator.cc index 1a88eacf50faab9906190feb463727fd26500517..ea8dab31de9be2869f2dd6f447f22eb3894ed288 100644 --- a/mace/core/operator.cc +++ b/mace/core/operator.cc @@ -1,4 +1,5 @@ - +// +// Copyright (c) 2017 XiaoMi All rights reserved. // #include diff --git a/mace/kernels/opencl/depth_to_space_opencl.cc b/mace/kernels/opencl/depth_to_space_opencl.cc index 23347c39dde1df961e79ddf5e6581ee29bd54151..c39c1a342c837e7aef4e9b5da03e401b012fc5e2 100644 --- a/mace/kernels/opencl/depth_to_space_opencl.cc +++ b/mace/kernels/opencl/depth_to_space_opencl.cc @@ -20,15 +20,22 @@ void DepthToSpaceOpFunctor::operator()( const index_t input_width = input->dim(2); const index_t input_depth = input->dim(3); + int depth_blocks = 1; + const char *kernel_name = nullptr; + index_t output_height, output_width, output_depth; if (d2s_) { output_height = input_height * block_size_; output_width = input_width * block_size_; output_depth = input_depth / (block_size_ * block_size_); + depth_blocks = RoundUpDiv4(output_depth); + kernel_name = "depth_to_space"; } else { output_height = input_height / block_size_; output_width = input_width / block_size_; output_depth = input_depth * block_size_ * block_size_; + depth_blocks = RoundUpDiv4(input_depth); + kernel_name = "space_to_depth"; } std::vector output_shape = {batch, output_height, output_width, @@ -38,11 +45,6 @@ void DepthToSpaceOpFunctor::operator()( CalImage2DShape(output_shape, BufferType::IN_OUT_CHANNEL, &image_shape); output->ResizeImage(output_shape, image_shape); - const int depth_blocks = - (d2s_) ? RoundUpDiv4(output_depth) : RoundUpDiv4(input_depth); - - const char *kernel_name = (d2s_) ? "depth_to_space" : "space_to_depth"; - if (kernel_.get() == nullptr) { auto runtime = OpenCLRuntime::Global(); std::set built_options;