Skip to content

Commit

Permalink
remove errno, paddle trapping floating point exceptions with feenable…
Browse files Browse the repository at this point in the history
…except
  • Loading branch information
hedaoyuan committed Nov 4, 2016
1 parent 2a93692 commit 8c2ad8d
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions paddle/math/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3406,9 +3406,7 @@ void CpuMatrix::tanh(Matrix& output) {
size_t dim = getWidth();
CHECK_EQ(output.getHeight(), numSamples);
CHECK_EQ(output.getWidth(), dim);
errno = 0;
vTanh(numSamples * dim, getData(), output.getData());
CHECK_EQ(errno, 0) << "vTanh error";
}

void CpuMatrix::tanhDerivative(Matrix& output) {
Expand All @@ -3430,10 +3428,8 @@ void CpuMatrix::softrelu(Matrix& output) {
out[j] = x;
}
}
errno = 0;
vExp(numSamples * dim, output.getData(), output.getData());
vLog1p(numSamples * dim, output.getData(), output.getData());
CHECK_EQ(errno, 0) << "vExp+vLog1p error";
}

void CpuMatrix::softreluDerivative(Matrix& output) {
Expand All @@ -3448,9 +3444,7 @@ void CpuMatrix::softreluDerivative(Matrix& output) {
MatrixPtr tmpMat = Matrix::create(numSamples, dim);
real* tmp = tmpMat->getData();

errno = 0;
vExp(size, output.getData(), tmpMat->getData());
CHECK_EQ(errno, 0) << "vExp error";

for (size_t i = 0; i < size; ++i) {
grad[i] *= (1.0 - 1.0 / tmp[i]);
Expand All @@ -3473,10 +3467,7 @@ void CpuMatrix::scaledTanh(Matrix& output, real p1, real p2) {
out[i] = p2 * in[i];
}

// out = tanh(out)
errno = 0;
vTanh(numSamples * dim, out, out);
CHECK_EQ(errno, 0) << "vTanh error";

// out = p1 * out
for (size_t i = 0; i < numSamples * dim; ++i) {
Expand Down

0 comments on commit 8c2ad8d

Please sign in to comment.