From 1ec66a334bb7a161b2f2cd75aeee0597eecdcf13 Mon Sep 17 00:00:00 2001 From: gaoyuan Date: Sat, 18 Mar 2017 15:49:08 +0800 Subject: [PATCH] change resizeOrCreate to create --- paddle/gserver/layers/CostLayer.cpp | 34 ++++++++++++----------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/paddle/gserver/layers/CostLayer.cpp b/paddle/gserver/layers/CostLayer.cpp index e2a4153bad7..4ae5b828707 100644 --- a/paddle/gserver/layers/CostLayer.cpp +++ b/paddle/gserver/layers/CostLayer.cpp @@ -206,17 +206,14 @@ bool SmoothL1CostLayer::init(const LayerMap& layerMap, void SmoothL1CostLayer::forwardImp(Matrix& output, Argument& label, Matrix& target) { - MatrixPtr targetCpu, labelCpu, outputCpu; + MatrixPtr targetCpu, outputCpu, labelCpu; if (useGpu_) { - Matrix::resizeOrCreate( - targetCpu, target.getHeight(), target.getWidth(), false, false); - Matrix::resizeOrCreate( - outputCpu, output.getHeight(), output.getWidth(), false, false); - Matrix::resizeOrCreate(labelCpu, - label.value->getHeight(), - label.value->getWidth(), - false, - false); + targetCpu = + Matrix::create(target.getHeight(), target.getWidth(), false, false); + outputCpu = + Matrix::create(output.getHeight(), output.getWidth(), false, false); + labelCpu = Matrix::create( + label.value->getHeight(), label.value->getWidth(), false, false); targetCpu->copyFrom(target); outputCpu->copyFrom(output); labelCpu->copyFrom(*label.value); @@ -230,17 +227,14 @@ void SmoothL1CostLayer::forwardImp(Matrix& output, void SmoothL1CostLayer::backwardImp(Matrix& output, Argument& label, Matrix& outputG) { - MatrixPtr outputGCpu, labelCpu, outputCpu; + MatrixPtr outputGCpu, outputCpu, labelCpu; if (useGpu_) { - Matrix::resizeOrCreate( - outputGCpu, outputG.getHeight(), outputG.getWidth(), false, false); - Matrix::resizeOrCreate( - outputCpu, output.getHeight(), output.getWidth(), false, false); - Matrix::resizeOrCreate(labelCpu, - label.value->getHeight(), - label.value->getWidth(), - false, - false); + outputGCpu = + Matrix::create(outputG.getHeight(), outputG.getWidth(), false, false); + outputCpu = + Matrix::create(output.getHeight(), output.getWidth(), false, false); + labelCpu = Matrix::create( + label.value->getHeight(), label.value->getWidth(), false, false); outputGCpu->copyFrom(outputG); outputCpu->copyFrom(output); labelCpu->copyFrom(*label.value); -- GitLab