提交 1ec66a33 编写于 作者: G gaoyuan

change resizeOrCreate to create

上级 25a525bb
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册