提交 5c2637eb 编写于 作者: D dzhwinter

tensor util

上级 52d60f8f
......@@ -137,7 +137,6 @@ void TensorCopySync(const Tensor& src, const platform::Place& dst_place,
#endif
}
/*
template <typename Predicate, typename DevCtx>
struct AnyDTypeVisitor {
Predicate predicate_;
......@@ -150,11 +149,7 @@ struct AnyDTypeVisitor {
: predicate_(predicate), tensor_(tensor), ctx_(ctx), out_(out) {}
template <typename T>
<<<<<<< HEAD
void apply()() const {
=======
void apply() const {
>>>>>>> origin/develop
auto t = EigenVector<T>::Flatten(tensor_);
auto o = EigenScalar<bool>::From(*out_);
// return any of predicate_(t) is true.
......@@ -178,7 +173,7 @@ struct AnyVisitor : public boost::static_visitor<bool> {
: tensor_(tensor), predicate_(std::move(predicate)) {}
template <typename Place>
bool apply()(const Place& place) const {
bool operator()(const Place& place) const {
framework::Tensor out;
out.Resize({1});
out.mutable_data<bool>(place);
......@@ -245,7 +240,6 @@ bool TensorContainsInf(const framework::Tensor& tensor) {
ContainsInfPredicate predicate;
return Any(tensor, predicate);
}
*/
void TensorToStream(std::ostream& os, const Tensor& tensor,
const platform::DeviceContext& dev_ctx) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册