!39211 Add assertion to fix codecheck error

Merge pull request !39211 from panzhihui/depthtospace_codecheck_fix
This commit is contained in:
i-robot 2022-08-01 07:42:48 +00:00 committed by Gitee
commit 5976090787
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 6 additions and 0 deletions

View File

@ -25,6 +25,7 @@ using complex64 = __complex__ float;
using complex128 = __complex__ double;
constexpr size_t kDepthToSpaceInputsNum = 1;
constexpr size_t kDepthToSpaceOutputsNum = 1;
constexpr size_t kDepthToSpaceInputDimension = 4;
} // namespace
void DepthToSpaceCpuKernelMod::InitKernel(const CNodePtr &kernel_node) {
@ -48,6 +49,11 @@ bool DepthToSpaceCpuKernelMod::LaunchKernel(const std::vector<kernel::AddressPtr
const std::vector<kernel::AddressPtr> &outputs) {
CHECK_KERNEL_INPUTS_NUM(inputs.size(), kDepthToSpaceInputsNum, kernel_name_);
CHECK_KERNEL_OUTPUTS_NUM(outputs.size(), kDepthToSpaceOutputsNum, kernel_name_);
auto input_rank = input_shape_.size();
if (input_rank != kDepthToSpaceInputDimension) {
MS_LOG(EXCEPTION) << "For " << kernel_name_ << ", the input should have a rank of 4, but got input of rank "
<< input_rank;
}
auto input_addr = reinterpret_cast<T *>(inputs[0]->addr);
auto output_addr = reinterpret_cast<T *>(outputs[0]->addr);
size_t size = inputs[0]->size / sizeof(T);