提交 7a7c8fd9 编写于 作者: T tensor-tang

simplify some comments and code

上级 59ccb01a
...@@ -315,7 +315,7 @@ void MKLDNNConvLayer::resetOutValue( ...@@ -315,7 +315,7 @@ void MKLDNNConvLayer::resetOutValue(
} else { } else {
cpuOutVal_ = out; cpuOutVal_ = out;
} }
// when output is cpu device, change the mkldnn output value and make they // when output is cpu device, change the mkldnn output value and make them
// share the same data. Then if next layer use inputlayer->getOuputValue() // share the same data. Then if next layer use inputlayer->getOuputValue()
// to achieve the input value, it will get the right data. // to achieve the input value, it will get the right data.
output_.value = std::dynamic_pointer_cast<Matrix>(cpuOutVal_); output_.value = std::dynamic_pointer_cast<Matrix>(cpuOutVal_);
......
...@@ -268,9 +268,9 @@ protected: ...@@ -268,9 +268,9 @@ protected:
/** /**
* reset the output grad matrix from primitive desc. * reset the output grad matrix from primitive desc.
* and reset the merge grad primitive if needed. * and reset the merge grad primitive if needed.
* note: when this layer have serval output, * note: when this layer has serval outputs,
* do not support mixing with cpu device, * it could not be mixed with cpu device,
* because can not get memory desc from cpu device. * since it can not get memory desc from cpu device.
*/ */
virtual void resetOutGrad(MKLDNNMatrixPtr& out, virtual void resetOutGrad(MKLDNNMatrixPtr& out,
mkldnn::memory::primitive_desc pd) { mkldnn::memory::primitive_desc pd) {
...@@ -281,7 +281,7 @@ protected: ...@@ -281,7 +281,7 @@ protected:
if (outputMap_.size() <= 1) { if (outputMap_.size() <= 1) {
return; return;
} }
std::vector<double> scales; std::vector<double> scales(outputMap_.size(), 1.0);
std::vector<mkldnn::memory::primitive_desc> srcPDs; std::vector<mkldnn::memory::primitive_desc> srcPDs;
std::vector<mkldnn::primitive::at> srcs; std::vector<mkldnn::primitive::at> srcs;
for (auto it = outputMap_.begin(); it != outputMap_.end(); ++it) { for (auto it = outputMap_.begin(); it != outputMap_.end(); ++it) {
...@@ -297,7 +297,6 @@ protected: ...@@ -297,7 +297,6 @@ protected:
} }
srcPDs.push_back(src->getPrimitiveDesc()); srcPDs.push_back(src->getPrimitiveDesc());
srcs.push_back(*src); srcs.push_back(*src);
scales.push_back(1.0);
} }
// TODO(TJ): remove me when mkldnn sum support different formats // TODO(TJ): remove me when mkldnn sum support different formats
......
...@@ -39,22 +39,18 @@ add_test(NAME test_CompareTwoNets ...@@ -39,22 +39,18 @@ add_test(NAME test_CompareTwoNets
################ test_CompareMKLDNNandCPU ###################### ################ test_CompareMKLDNNandCPU ######################
if(WITH_MKLDNN) if(WITH_MKLDNN)
add_unittest_without_exec(test_CompareMKLDNNandCPU macro(gen_command VAR_NAME CONFIG_FILE)
test_CompareTwoNets.cpp) set(${VAR_NAME} "${PADDLE_SOURCE_DIR}/paddle/.set_python_path.sh" "-d" "${PADDLE_SOURCE_DIR}/python/"
add_test(NAME test_CompareMKLDNNandCPU "${CMAKE_CURRENT_BINARY_DIR}/test_CompareMKLDNNandCPU --use_gpu=False"
COMMAND ${PADDLE_SOURCE_DIR}/paddle/.set_python_path.sh -d ${PADDLE_SOURCE_DIR}/python/ "--config_file_a=trainer/tests/${CONFIG_FILE} --use_mkldnn_a=True"
${CMAKE_CURRENT_BINARY_DIR}/test_CompareMKLDNNandCPU "--config_file_b=trainer/tests/${CONFIG_FILE} --use_mkldnn_b=False"
--config_file_a=trainer/tests/sample_trainer_config_simple_net.conf --use_mkldnn_a=True "WORKING_DIRECTORY" "${PADDLE_SOURCE_DIR}/paddle/")
--config_file_b=trainer/tests/sample_trainer_config_simple_net.conf --use_mkldnn_b=False endmacro()
--use_gpu=False add_unittest_without_exec(test_CompareMKLDNNandCPU test_CompareTwoNets.cpp)
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}/paddle/) gen_command(compare_simple_net "sample_trainer_config_simple_net.conf")
add_test(NAME test_CompareMKLDNNandCPU_Banches gen_command(compare_branch_net "sample_trainer_config_branch_net.conf")
COMMAND ${PADDLE_SOURCE_DIR}/paddle/.set_python_path.sh -d ${PADDLE_SOURCE_DIR}/python/ add_test(NAME test_CompareMKLDNNandCPU_simple_net COMMAND ${compare_simple_net})
${CMAKE_CURRENT_BINARY_DIR}/test_CompareMKLDNNandCPU add_test(NAME test_CompareMKLDNNandCPU_branch_net COMMAND ${compare_branch_net})
--config_file_a=trainer/tests/sample_trainer_config_branch_net.conf --use_mkldnn_a=True
--config_file_b=trainer/tests/sample_trainer_config_branch_net.conf --use_mkldnn_b=False
--use_gpu=False
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}/paddle/)
endif() endif()
############### test_CompareTwoOpts ################### ############### test_CompareTwoOpts ###################
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册