@@ -451,6 +451,7 @@ void GpuMatrix::addSharedBias(Matrix& b, real scale) {
451
451
}
452
452
453
453
void GpuMatrix::collectBias (Matrix& a, real scale) {
454
+ #ifdef PADDLE_WITH_CUDA
454
455
CHECK_EQ (getHeight (), (size_t )1 );
455
456
CHECK_EQ (width_, a.getWidth ());
456
457
GpuSparseMatrix* sMatPtr = dynamic_cast <GpuSparseMatrix*>(&a);
@@ -461,6 +462,7 @@ void GpuMatrix::collectBias(Matrix& a, real scale) {
461
462
hl_sparse_matrix_s A_d = sMatPtr ->sMatrix_ .get ();
462
463
hl_sparse_matrix_column_sum (data, A_d, sMatPtr ->getHeight (), width_, scale);
463
464
}
465
+ #endif
464
466
}
465
467
466
468
void GpuMatrix::collectSharedBias (Matrix& a, real scale) {
@@ -552,6 +554,7 @@ void GpuMatrix::mul(const GpuSparseMatrix& a,
552
554
const GpuMatrix& b,
553
555
real scaleAB,
554
556
real scaleT) {
557
+ #ifdef PADDLE_WITH_CUDA
555
558
CHECK (isContiguous ());
556
559
CHECK (b.isContiguous ());
557
560
CHECK (b.useGpu_ == true ) << " Matrix type are not equal" ;
@@ -578,12 +581,14 @@ void GpuMatrix::mul(const GpuSparseMatrix& a,
578
581
b.height_ ,
579
582
scaleAB,
580
583
scaleT);
584
+ #endif
581
585
}
582
586
583
587
void GpuMatrix::mul (const GpuMatrix& a,
584
588
const GpuSparseMatrix& b,
585
589
real scaleAB,
586
590
real scaleT) {
591
+ #ifdef PADDLE_WITH_CUDA
587
592
CHECK (isContiguous ());
588
593
CHECK (a.isContiguous ());
589
594
CHECK (a.useGpu_ == true ) << " Matrix type are not equal" ;
@@ -622,6 +627,7 @@ void GpuMatrix::mul(const GpuMatrix& a,
622
627
scaleAB,
623
628
scaleT);
624
629
}
630
+ #endif
625
631
}
626
632
627
633
/* this = a*b */
@@ -1548,6 +1554,7 @@ void GpuMatrix::bilinearBackward(const Matrix& out,
1548
1554
}
1549
1555
1550
1556
void GpuMatrix::multiBinaryLabelCrossEntropy (Matrix& output, Matrix& label) {
1557
+ #ifdef PADDLE_WITH_CUDA
1551
1558
GpuMatrix* outputPtr = dynamic_cast <GpuMatrix*>(&output);
1552
1559
auto labelPtr = dynamic_cast <GpuSparseMatrix*>(&label);
1553
1560
@@ -1563,9 +1570,11 @@ void GpuMatrix::multiBinaryLabelCrossEntropy(Matrix& output, Matrix& label) {
1563
1570
hl_sparse_matrix_s mat_d = labelPtr->sMatrix_ .get ();
1564
1571
hl_matrix_multi_binary_cross_entropy (
1565
1572
output_d, entropy_d, mat_d, height_, outputPtr->width_ );
1573
+ #endif
1566
1574
}
1567
1575
1568
1576
void GpuMatrix::multiBinaryLabelCrossEntropyBp (Matrix& output, Matrix& label) {
1577
+ #ifdef PADDLE_WITH_CUDA
1569
1578
GpuMatrix* outputPtr = dynamic_cast <GpuMatrix*>(&output);
1570
1579
auto labelPtr = dynamic_cast <GpuSparseMatrix*>(&label);
1571
1580
@@ -1581,6 +1590,7 @@ void GpuMatrix::multiBinaryLabelCrossEntropyBp(Matrix& output, Matrix& label) {
1581
1590
hl_sparse_matrix_s mat_d = labelPtr->sMatrix_ .get ();
1582
1591
hl_matrix_multi_binary_cross_entropy_bp (
1583
1592
output_d, grad_d, mat_d, height_, width_);
1593
+ #endif
1584
1594
}
1585
1595
1586
1596
void GpuMatrix::vol2Col (real* dataSrc,
@@ -3226,6 +3236,7 @@ template void CpuMatrix::mul<CpuMatrix, CacheRowCpuMatrix>(CpuSparseMatrix* a,
3226
3236
real scaleAB,
3227
3237
real scaleT);
3228
3238
3239
+ #ifndef PADDLE_MOBILE_INFERENCE
3229
3240
void SharedCpuMatrix::mul (CpuSparseMatrix* a,
3230
3241
CpuMatrix* b,
3231
3242
real scaleAB,
@@ -3354,6 +3365,7 @@ void SharedCpuMatrix::initBlock(int blockNum) {
3354
3365
}
3355
3366
}
3356
3367
3368
+ #endif
3357
3369
/* Add a (column) vector b to matrix a, column by column */
3358
3370
void CpuMatrix::addColumnVector (const Matrix& b) {
3359
3371
BaseMatrix::addColVector (const_cast <Matrix&>(b));
0 commit comments