use correct input shape to calculate strides

This commit is contained in:
zhaozhenlong 2020-09-17 10:40:46 +08:00
parent cc795083de
commit b491055a70
1 changed files with 1 additions and 2 deletions

View File

@ -201,10 +201,9 @@ int PadCPUKernel::CopyPaddingFromInput() {
}
void PadCPUKernel::CalculateStrides() {
auto input_shape = in_tensors_.at(0)->shape();
pad_param_->in_strides[DEFAULT_PAD_NDIMS - 1] = 1;
for (auto i = DEFAULT_PAD_NDIMS - 2; i >= 0; --i) {
pad_param_->in_strides[i] = input_shape[i + 1] * pad_param_->in_strides[i + 1];
pad_param_->in_strides[i] = in_[i + 1] * pad_param_->in_strides[i + 1];
}
for (auto i = 0; i < DEFAULT_PAD_NDIMS; ++i) {
out_[i] = in_[i] + pad_param_->paddings_[i * 2] + pad_param_->paddings_[i * 2 + 1];