@Namespace(value="nvinfer1") public static enum nvinfer.PaddingMode extends Enum<nvinfer.PaddingMode>
Shorthand:
I = dimensions of input image.
B = prePadding, before the image data. For deconvolution, prePadding is set before output.
A = postPadding, after the image data. For deconvolution, postPadding is set after output.
P = delta between input and output
S = stride
F = filter
O = output
D = dilation
M = I + B + A ; The image data plus any padding
DK = 1 + D * (F - 1)
Formulas for Convolution:
- EXPLICIT_ROUND_DOWN:
O = floor((M - DK) / S) + 1
- CAFFE_ROUND_DOWN:
O = floor((I + B * 2 - DK) / S) + 1
- EXPLICIT_ROUND_UP:
O = ceil((M - DK) / S) + 1
- CAFFE_ROUND_UP:
O = ceil((I + B * 2 - DK) / S) + 1
- SAME_UPPER:
O = ceil(I / S)
P = floor((I - 1) / S) * S + DK - I;
B = floor(P / 2)
A = P - B
- SAME_LOWER:
O = ceil(I / S)
P = floor((I - 1) / S) * S + DK - I;
A = floor(P / 2)
B = P - A
Formulas for Deconvolution:
- EXPLICIT_ROUND_DOWN:
- CAFFE_ROUND_DOWN:
- EXPLICIT_ROUND_UP:
- CAFFE_ROUND_UP:
O = (I - 1) * S + DK - (B + A)
- SAME_UPPER:
O = min(I * S, (I - 1) * S + DK)
P = max(DK - S, 0)
B = floor(P / 2)
A = P - B
- SAME_LOWER:
O = min(I * S, (I - 1) * S + DK)
P = max(DK - S, 0)
A = floor(P / 2)
B = P - A
Formulas for Pooling:
- EXPLICIT_ROUND_DOWN:
O = floor((M - F) / S) + 1
- EXPLICIT_ROUND_UP:
O = ceil((M - F) / S) + 1
- SAME_UPPER:
O = ceil(I / S)
P = floor((I - 1) / S) * S + F - I;
B = floor(P / 2)
A = P - B
- SAME_LOWER:
O = ceil(I / S)
P = floor((I - 1) / S) * S + F - I;
A = floor(P / 2)
B = P - A
- CAFFE_ROUND_DOWN:
EXPLICIT_ROUND_DOWN - ((EXPLICIT_ROUND_DOWN - 1) * S >= I + B)
- CAFFE_ROUND_UP:
EXPLICIT_ROUND_UP - ((EXPLICIT_ROUND_UP - 1) * S >= I + B)
Pooling Example 1:
Given I = {6, 6}, B = {3, 3}, A = {2, 2}, S = {2, 2}, F = {3, 3}. What is O?
(B, A can be calculated for SAME_UPPER and SAME_LOWER mode)
- EXPLICIT_ROUND_DOWN:
Computation:
M = {6, 6} + {3, 3} + {2, 2} ==> {11, 11}
O ==> floor((M - F) / S) + 1
==> floor(({11, 11} - {3, 3}) / {2, 2}) + {1, 1}
==> floor({8, 8} / {2, 2}) + {1, 1}
==> {5, 5}
- EXPLICIT_ROUND_UP:
Computation:
M = {6, 6} + {3, 3} + {2, 2} ==> {11, 11}
O ==> ceil((M - F) / S) + 1
==> ceil(({11, 11} - {3, 3}) / {2, 2}) + {1, 1}
==> ceil({8, 8} / {2, 2}) + {1, 1}
==> {5, 5}
The sample points are {0, 2, 4, 6, 8} in each dimension.
- SAME_UPPER:
Computation:
I = {6, 6}
S = {2, 2}
O = ceil(I / S) = {3, 3}
P = floor((I - 1) / S) * S + F - I
==> floor(({6, 6} - {1, 1}) / {2, 2}) * {2, 2} + {3, 3} - {6, 6}
==> {4, 4} + {3, 3} - {6, 6}
==> {1, 1}
B = floor({1, 1} / {2, 2})
==> {0, 0}
A = {1, 1} - {0, 0}
==> {1, 1}
- SAME_LOWER:
Computation:
I = {6, 6}
S = {2, 2}
O = ceil(I / S) = {3, 3}
P = floor((I - 1) / S) * S + F - I
==> {1, 1}
A = floor({1, 1} / {2, 2})
==> {0, 0}
B = {1, 1} - {0, 0}
==> {1, 1}
The sample pointers are {0, 2, 4} in each dimension.
SAMPLE_UPPER has {O0, O1, O2, pad} in output in each dimension.
SAMPLE_LOWER has {pad, O0, O1, O2} in output in each dimension.
Pooling Example 2:
Given I = {6, 6}, B = {3, 3}, A = {3, 3}, S = {2, 2}, F = {3, 3}. What is O?
- CAFFE_ROUND_DOWN:
Computation:
M = {6, 6} + {3, 3} + {3, 3} ==> {12, 12}
EXPLICIT_ROUND_DOWN ==> floor((M - F) / S) + 1
==> floor(({12, 12} - {3, 3}) / {2, 2}) + {1, 1}
==> {5, 5}
DIFF = (((EXPLICIT_ROUND_DOWN - 1) * S >= I + B) ? {1, 1} : {0, 0})
==> ({5, 5} - {1, 1}) * {2, 2} >= {6, 6} + {3, 3} ? {1, 1} : {0,0}
==> {0, 0}
O ==> EXPLICIT_ROUND_DOWN - DIFF
==> {5, 5} - {0, 0}
==> {5, 5}
- CAFFE_ROUND_UP:
Computation:
M = {6, 6} + {3, 3} + {3, 3} ==> {12, 12}
EXPLICIT_ROUND_UP ==> ceil((M - F) / S) + 1
==> ceil(({12, 12} - {3, 3}) / {2, 2}) + {1, 1}
==> {6, 6}
DIFF = (((EXPLICIT_ROUND_UP - 1) * S >= I + B) ? {1, 1} : {0, 0})
==> ({6, 6} - {1, 1}) * {2, 2} >= {6, 6} + {3, 3} ? {1, 1} : {0,0}
==> {1, 1}
O ==> EXPLICIT_ROUND_UP - DIFF
==> {6, 6} - {1, 1}
==> {5, 5}
The sample points are {0, 2, 4, 6, 8} in each dimension.
CAFFE_ROUND_DOWN: B >= F is an error if (B - S) < F
CAFFE_ROUND_UP: (B + S) >= (F + 1) is an error if B < (F + 1)
- Restriction 2:
CAFFE_ROUND_DOWN: (B - S) >= F is an error if B >= F
CAFFE_ROUND_UP: B >= (F + 1) is an error if (B + S) >= (F + 1)
Enum Constant and Description |
---|
kCAFFE_ROUND_DOWN
Use CAFFE padding, rounding output size down, uses prePadding value.
|
kCAFFE_ROUND_UP
Use CAFFE padding, rounding output size up, uses prePadding value.
|
kEXPLICIT_ROUND_DOWN
Use explicit padding, rounding output size down.
|
kEXPLICIT_ROUND_UP
Use explicit padding, rounding output size up.
|
kSAME_LOWER
Use SAME padding, with prePadding >= postPadding.
|
kSAME_UPPER
Use SAME padding, with prePadding <= postPadding.
|
Modifier and Type | Field and Description |
---|---|
int |
value |
Modifier and Type | Method and Description |
---|---|
nvinfer.PaddingMode |
intern() |
String |
toString() |
static nvinfer.PaddingMode |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static nvinfer.PaddingMode[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final nvinfer.PaddingMode kEXPLICIT_ROUND_DOWN
public static final nvinfer.PaddingMode kEXPLICIT_ROUND_UP
public static final nvinfer.PaddingMode kSAME_UPPER
public static final nvinfer.PaddingMode kSAME_LOWER
public static final nvinfer.PaddingMode kCAFFE_ROUND_DOWN
public static final nvinfer.PaddingMode kCAFFE_ROUND_UP
public static nvinfer.PaddingMode[] values()
for (nvinfer.PaddingMode c : nvinfer.PaddingMode.values()) System.out.println(c);
public static nvinfer.PaddingMode valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic nvinfer.PaddingMode intern()
public String toString()
toString
in class Enum<nvinfer.PaddingMode>
Copyright © 2024. All rights reserved.