Closed hedaoyuan closed 7 years ago
Defines the data structure of the input, output and filter.(NCHW or NHWC? filter?)
NNPACK only supports NCHW. cuDNN supports NCHW by default. Maybe we can only support NCHW layout.
Output size calculation. (At present, there are several places that define the calculation method of the output size.)
It's better to calculate output size each mini-batch.
At present ConvLayer and ConvTransLayer are written two implementations. For example, ExpandConvLayer and ExpandConvTransLayer are implemented in ExpandConvLayer.cpp
and ExpandConvTransLayer.cpp
files respectively. By comparison found that the two code logic is basically the same. After adding the ConvFunction, we can combine the two codes into one code.
// file: ExpandConvLayer.cpp
REGISTER_LAYER(exconv, ExpandConvLayer);
bool ExpandConvLayer::init(const LayerMap &layerMap,
const ParameterMap ¶meterMap) {
/* Initialize the basic convolutional parent class */
ExpandConvBaseLayer::init(layerMap, parameterMap);
return true;
}
...
// file: ExpandConvTransLayer.cpp
REGISTER_LAYER(exconvt, ExpandConvTransLayer);
bool ExpandConvTransLayer::init(const LayerMap &layerMap,
const ParameterMap ¶meterMap) {
/* Initialize the basic convolutional parent class */
ExpandConvBaseLayer::init(layerMap, parameterMap);
return true;
}
...
// file: ExpandConvLayer.cpp
REGISTER_LAYER(exconv, ExpandConvLayer);
REGISTER_LAYER(exconvt, ExpandConvLayer);
bool ExpandConvLayer::init(const LayerMap &layerMap,
const ParameterMap ¶meterMap) {
/* Initialize the basic convolutional parent class */
ExpandConvBaseLayer::init(layerMap, parameterMap);
if (config.type() == "exconv") {
forwardFunction = expandFwdOnce;
backwardFunction = bpropActs
} else { /* config.type() == "exconvt" */
forwardFunction = bpropActs;
backwardFunction = expandFwdOnce;
}
return true;
}
...
For some reason, we need to reconstruct the convolution-related code #2177 . In addition to performance considerations, how to make paddle convolution-related code clearer and more readable is the primary purpose.
So, the whole refactoring process needs to figure out the following things: