From 988e49defa37424caf9f711e953a612b0d6993b6 Mon Sep 17 00:00:00 2001 From: Liu Yiqun Date: Fri, 1 Sep 2017 10:05:42 +0800 Subject: [PATCH] Fix clang compiling error of "moving a temporary object prevents copy elision" causing by std::move, and fix some warnings. --- paddle/gserver/layers/CrossEntropyOverBeam.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/paddle/gserver/layers/CrossEntropyOverBeam.cpp b/paddle/gserver/layers/CrossEntropyOverBeam.cpp index 4acc07703..578bdbbe7 100644 --- a/paddle/gserver/layers/CrossEntropyOverBeam.cpp +++ b/paddle/gserver/layers/CrossEntropyOverBeam.cpp @@ -223,7 +223,7 @@ void CrossEntropyOverBeam::checkInputs() { << inputLayers_[i * 3]->getName() << " should be a nested sequence"; CHECK_EQ(getInputValue(i * 3 + 1)->getWidth(), beamSize_); - CHECK_EQ(scores.getNumSequences(), batchSize_); + CHECK_EQ(batchSize_, static_cast(scores.getNumSequences())); CHECK_EQ(scores.getNumSubSequences(), selCandidates.getBatchSize()); } else { CHECK(scores.hasSeq()) << "input " << i << " " @@ -231,10 +231,10 @@ void CrossEntropyOverBeam::checkInputs() { << " should be a sequence"; batchSize_ = scores.getNumSequences(); beamSize_ = getInputValue(i * 3 + 1)->getWidth(); - CHECK_EQ(batchSize_, selCandidates.getBatchSize()); + CHECK_EQ(batchSize_, static_cast(selCandidates.getBatchSize())); } CHECK_EQ(1U, scores.value->getWidth()); - CHECK_EQ(batchSize_, goldSeq.getBatchSize()); + CHECK_EQ(batchSize_, static_cast(goldSeq.getBatchSize())); } } @@ -377,8 +377,8 @@ void CrossEntropyOverBeam::forward(PassType passType) { MatrixPtr outputValue = getOutputValue(); for (size_t i = 0; i < batchSize_; ++i) { - beamCosts_[i].setData( - std::move(std::make_shared(beamPerSeq_[i])), beamSize_); + BeamExpansionPtr ptr = std::make_shared(beamPerSeq_[i]); + beamCosts_[i].setData(std::move(ptr), beamSize_); outputValue->getData()[i] = beamCosts_[i].forward(); } } -- GitLab