@@ -206,17 +206,14 @@ bool SmoothL1CostLayer::init(const LayerMap& layerMap,
206
206
void SmoothL1CostLayer::forwardImp (Matrix& output,
207
207
Argument& label,
208
208
Matrix& target) {
209
- MatrixPtr targetCpu, labelCpu, outputCpu ;
209
+ MatrixPtr targetCpu, outputCpu, labelCpu ;
210
210
if (useGpu_) {
211
- Matrix::resizeOrCreate (
212
- targetCpu, target.getHeight (), target.getWidth (), false , false );
213
- Matrix::resizeOrCreate (
214
- outputCpu, output.getHeight (), output.getWidth (), false , false );
215
- Matrix::resizeOrCreate (labelCpu,
216
- label.value ->getHeight (),
217
- label.value ->getWidth (),
218
- false ,
219
- false );
211
+ targetCpu =
212
+ Matrix::create (target.getHeight (), target.getWidth (), false , false );
213
+ outputCpu =
214
+ Matrix::create (output.getHeight (), output.getWidth (), false , false );
215
+ labelCpu = Matrix::create (
216
+ label.value ->getHeight (), label.value ->getWidth (), false , false );
220
217
targetCpu->copyFrom (target);
221
218
outputCpu->copyFrom (output);
222
219
labelCpu->copyFrom (*label.value );
@@ -230,17 +227,14 @@ void SmoothL1CostLayer::forwardImp(Matrix& output,
230
227
void SmoothL1CostLayer::backwardImp (Matrix& output,
231
228
Argument& label,
232
229
Matrix& outputG) {
233
- MatrixPtr outputGCpu, labelCpu, outputCpu ;
230
+ MatrixPtr outputGCpu, outputCpu, labelCpu ;
234
231
if (useGpu_) {
235
- Matrix::resizeOrCreate (
236
- outputGCpu, outputG.getHeight (), outputG.getWidth (), false , false );
237
- Matrix::resizeOrCreate (
238
- outputCpu, output.getHeight (), output.getWidth (), false , false );
239
- Matrix::resizeOrCreate (labelCpu,
240
- label.value ->getHeight (),
241
- label.value ->getWidth (),
242
- false ,
243
- false );
232
+ outputGCpu =
233
+ Matrix::create (outputG.getHeight (), outputG.getWidth (), false , false );
234
+ outputCpu =
235
+ Matrix::create (output.getHeight (), output.getWidth (), false , false );
236
+ labelCpu = Matrix::create (
237
+ label.value ->getHeight (), label.value ->getWidth (), false , false );
244
238
outputGCpu->copyFrom (outputG);
245
239
outputCpu->copyFrom (output);
246
240
labelCpu->copyFrom (*label.value );
0 commit comments