MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / handle_padding

Function handle_padding

dnn/src/arm_common/pooling/algo.cpp:63–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63const int8_t* handle_padding(
64 const int8_t* src, size_t IH, size_t IW, size_t& IH2, size_t& IW2, size_t PH,
65 size_t PW, const WorkspaceBundle& ws, bool is_max_mode) {
66 int8_t* sptr_base = nullptr;
67 int8_t padding_value = is_max_mode ? INT8_MIN : 0;
68 bool need_pad = ((PH != 0) || (PW != 0)) ? true : false;
69 if (need_pad) {
70 IH2 = IH + 2 * PH;
71 IW2 = IW + 2 * PW;
72 sptr_base = static_cast<int8_t*>(ws.get(0));
73 memset(sptr_base, padding_value, sizeof(int8_t) * IH2 * IW2 * 4);
74 rep(ih, IH) {
75 std::memcpy(
76 sptr_base + (ih + PH) * IW2 * 4 + PW * 4, src + ih * IW * 4,
77 sizeof(int8_t) * IW * 4);
78 }
79 } else {
80 IH2 = IH;
81 IW2 = IW;
82 }
83 return need_pad ? sptr_base : src;
84}
85
86bool PoolingImpl::AlgoFilterxModexStride1::usable(
87 const PoolingKernSizeParam& param) const {

Calls 1

getMethod · 0.45

Tested by

no test coverage detected