提交 f62f5181 编写于 作者: Y Yu Yang

Use explicit type for std::transform.

* Also fix a protential bug in WarpCTCLayer.cpp
上级 d5c0eeda
...@@ -31,7 +31,6 @@ bool WarpCTCLayer::init(const LayerMap& layerMap, ...@@ -31,7 +31,6 @@ bool WarpCTCLayer::init(const LayerMap& layerMap,
CHECK_EQ(numClasses_, inputLayers_[0]->getSize()); CHECK_EQ(numClasses_, inputLayers_[0]->getSize());
blank_ = config_.blank(); blank_ = config_.blank();
CHECK_GE(blank_, 0UL);
CHECK_LT(blank_, numClasses_); CHECK_LT(blank_, numClasses_);
normByTimes_ = config_.norm_by_times(); normByTimes_ = config_.norm_by_times();
......
...@@ -611,10 +611,7 @@ void PreparedOperations::addOperationHelper(Operation* op, CpuMatrixPtr mat) { ...@@ -611,10 +611,7 @@ void PreparedOperations::addOperationHelper(Operation* op, CpuMatrixPtr mat) {
pmat.mutable_values(), mat->getData(), pmat.num_cols() * pmat.num_rows()); pmat.mutable_values(), mat->getData(), pmat.num_cols() * pmat.num_rows());
} }
template <typename T1, typename T2> static inline real addTwo(real a, double b) { return a + b; }
static inline auto add(T1 a, T2 b) -> decltype(a + b) {
return a + b;
}
void ParameterClient2::doOperation(PreparedOperations& ops, void ParameterClient2::doOperation(PreparedOperations& ops,
bool waitForGradient, bool waitForGradient,
...@@ -684,7 +681,7 @@ void ParameterClient2::doOperation(PreparedOperations& ops, ...@@ -684,7 +681,7 @@ void ParameterClient2::doOperation(PreparedOperations& ops,
rvec->getData() + rvec->getSize(), rvec->getData() + rvec->getSize(),
vec.values().data(), vec.values().data(),
rvec->getData(), rvec->getData(),
add<real, double>); addTwo);
} }
CHECK_EQ(resultMatrices.size(), (size_t)result.matrices_size()); CHECK_EQ(resultMatrices.size(), (size_t)result.matrices_size());
...@@ -699,7 +696,7 @@ void ParameterClient2::doOperation(PreparedOperations& ops, ...@@ -699,7 +696,7 @@ void ParameterClient2::doOperation(PreparedOperations& ops,
rmat->getData() + rmat->getElementCnt(), rmat->getData() + rmat->getElementCnt(),
mat.values().data(), mat.values().data(),
rmat->getData(), rmat->getData(),
add<real, double>); addTwo);
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册