1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/*
* Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
* Copyright (c) 2016-2018 ARM Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "arm_compute/core/UtilsEx.h"
#include "arm_compute/core/Error.h"
using namespace arm_compute;
const std::pair<unsigned int, unsigned int>
arm_compute::transposeconv_output_dimensions(unsigned int in_width, unsigned int in_height,
unsigned int kernel_width, unsigned int kernel_height,
const PadStrideInfo &info, unsigned int invalid_right,
unsigned int invalid_bottom)
{
const unsigned int stride_x = info.stride().first;
const unsigned int stride_y = info.stride().second;
const unsigned int padx = info.pad_left() + info.pad_right();
const unsigned int pady = info.pad_top() + info.pad_bottom();
ARM_COMPUTE_ERROR_ON(in_width < 1 || in_height < 1);
ARM_COMPUTE_ERROR_ON(kernel_width <= padx);
ARM_COMPUTE_ERROR_ON(kernel_height <= pady);
// Find the transpose conv out dimensions
// transpose conv out:
// tconv_out + pad = 1 + (in - 1) * stride + invalid
// tconv_out = 1 + (in - 1) * stride + invalid - pad
const int w = stride_x * (in_width - 1) + kernel_width - padx + invalid_right;
const int h = stride_y * (in_height - 1) + kernel_height - pady + invalid_bottom;
return std::make_pair<unsigned int, unsigned int>(w, h);
}
|