提交 988e49de 编写于 作者: L Liu Yiqun

Fix clang compiling error of "moving a temporary object prevents copy elision"...

Fix clang compiling error of "moving a temporary object prevents copy elision" causing by std::move, and fix some warnings.
上级 0ea4e258
...@@ -223,7 +223,7 @@ void CrossEntropyOverBeam::checkInputs() { ...@@ -223,7 +223,7 @@ void CrossEntropyOverBeam::checkInputs() {
<< inputLayers_[i * 3]->getName() << inputLayers_[i * 3]->getName()
<< " should be a nested sequence"; << " should be a nested sequence";
CHECK_EQ(getInputValue(i * 3 + 1)->getWidth(), beamSize_); CHECK_EQ(getInputValue(i * 3 + 1)->getWidth(), beamSize_);
CHECK_EQ(scores.getNumSequences(), batchSize_); CHECK_EQ(batchSize_, static_cast<size_t>(scores.getNumSequences()));
CHECK_EQ(scores.getNumSubSequences(), selCandidates.getBatchSize()); CHECK_EQ(scores.getNumSubSequences(), selCandidates.getBatchSize());
} else { } else {
CHECK(scores.hasSeq()) << "input " << i << " " CHECK(scores.hasSeq()) << "input " << i << " "
...@@ -231,10 +231,10 @@ void CrossEntropyOverBeam::checkInputs() { ...@@ -231,10 +231,10 @@ void CrossEntropyOverBeam::checkInputs() {
<< " should be a sequence"; << " should be a sequence";
batchSize_ = scores.getNumSequences(); batchSize_ = scores.getNumSequences();
beamSize_ = getInputValue(i * 3 + 1)->getWidth(); beamSize_ = getInputValue(i * 3 + 1)->getWidth();
CHECK_EQ(batchSize_, selCandidates.getBatchSize()); CHECK_EQ(batchSize_, static_cast<size_t>(selCandidates.getBatchSize()));
} }
CHECK_EQ(1U, scores.value->getWidth()); CHECK_EQ(1U, scores.value->getWidth());
CHECK_EQ(batchSize_, goldSeq.getBatchSize()); CHECK_EQ(batchSize_, static_cast<size_t>(goldSeq.getBatchSize()));
} }
} }
...@@ -377,8 +377,8 @@ void CrossEntropyOverBeam::forward(PassType passType) { ...@@ -377,8 +377,8 @@ void CrossEntropyOverBeam::forward(PassType passType) {
MatrixPtr outputValue = getOutputValue(); MatrixPtr outputValue = getOutputValue();
for (size_t i = 0; i < batchSize_; ++i) { for (size_t i = 0; i < batchSize_; ++i) {
beamCosts_[i].setData( BeamExpansionPtr ptr = std::make_shared<BeamExpansion>(beamPerSeq_[i]);
std::move(std::make_shared<BeamExpansion>(beamPerSeq_[i])), beamSize_); beamCosts_[i].setData(std::move(ptr), beamSize_);
outputValue->getData()[i] = beamCosts_[i].forward(); outputValue->getData()[i] = beamCosts_[i].forward();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册