MCPcopy Create free account
hub / github.com/ROCm/AMDMIGraphX / calculate_padding

Function calculate_padding

src/pad_calc.cpp:55–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void calculate_padding(int64_t idx,
56 std::vector<int64_t>& pads,
57 int64_t input_dim,
58 int64_t stride,
59 int64_t dilation,
60 int64_t weight_dim,
61 bool is_same_upper)
62{
63 int64_t output_dim = (input_dim + stride - 1) / stride; // round up result
64 int64_t new_weight_dim = weight_dim + (weight_dim - 1) * (dilation - 1);
65 int64_t pad =
66 std::max(static_cast<int64_t>(0), (output_dim - 1) * stride + new_weight_dim - input_dim);
67 auto pad_ndims = pads.size() / 2;
68
69 if(is_same_upper)
70 {
71 pads[idx] = pad / 2;
72 pads[idx + pad_ndims] = pad - pad / 2;
73 }
74 else
75 {
76 pads[idx + pad_ndims] = pad / 2;
77 pads[idx] = pad - pad / 2;
78 }
79}
80
81/**
82 * Given the input array dimensions; kernel (wei_lens); strides; and dilations,

Callers 6

TEST_CASEFunction · 0.85
lower_lrn_to_poolingFunction · 0.85
calc_auto_paddingFunction · 0.85
parseMethod · 0.85
parseMethod · 0.85
parseMethod · 0.85

Calls 2

maxClass · 0.50
sizeMethod · 0.45

Tested by 1

TEST_CASEFunction · 0.68