From 89b9d86d9d676a756357341fa9d8b0d1efec2f48 Mon Sep 17 00:00:00 2001 From: sneaxiy Date: Thu, 20 Dec 2018 10:43:44 +0000 Subject: [PATCH] fix windows compile bug test=develop --- paddle/fluid/framework/ddim.cc | 16 +++++++++++----- paddle/fluid/framework/ddim.h | 6 ------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/paddle/fluid/framework/ddim.cc b/paddle/fluid/framework/ddim.cc index 033d780fa..95078093e 100644 --- a/paddle/fluid/framework/ddim.cc +++ b/paddle/fluid/framework/ddim.cc @@ -62,7 +62,8 @@ struct DDimPlusVisitor { DDim DDim::operator+(const DDim& d) const { PADDLE_ENFORCE(rank_ == d.rank_); - DDim ret(rank_); + DDim ret; + ret.rank_ = rank_; ret.apply_visitor(DDimPlusVisitor(Get(), d.Get())); return ret; } @@ -82,7 +83,8 @@ struct DDimMulVisitor { DDim DDim::operator*(const DDim& d) const { PADDLE_ENFORCE(rank_ == d.rank_); - DDim ret(rank_); + DDim ret; + ret.rank_ = rank_; ret.apply_visitor(DDimMulVisitor(Get(), d.Get())); return ret; } @@ -121,7 +123,9 @@ int64_t product(const DDim& ddim) { DDim slice_ddim(const DDim& dim, int begin, int end) { PADDLE_ENFORCE(begin >= 0, "Begin index can't be less than zero in ddim slice."); - DDim ret(end - begin); + int len = end - begin; + DDim ret; + ret.rank_ = len; dynamic_dim_assign(dim.Get() + begin, ret.GetMutable(), ret.rank_); return ret; } @@ -156,7 +160,8 @@ DDim flatten_to_2d(const DDim& src, int num_col_dims) { DDim flatten_to_1d(const DDim& src) { return make_ddim({product(src)}); } DDim stride(const DDim& ddim) { - DDim strides(ddim.size()); + DDim strides; + strides.rank_ = ddim.size(); strides[ddim.size() - 1] = 1; for (int i = ddim.size() - 2; i >= 0; --i) { strides[i] = strides[i + 1] * ddim[i + 1]; @@ -165,7 +170,8 @@ DDim stride(const DDim& ddim) { } DDim stride_numel(const DDim& ddim) { - DDim strides(ddim.size()); + DDim strides; + strides.rank_ = ddim.size(); strides[ddim.size() - 1] = ddim[ddim.size() - 1]; for (int i = ddim.size() - 2; i >= 0; --i) { strides[i] = strides[i + 1] * ddim[i]; diff --git a/paddle/fluid/framework/ddim.h b/paddle/fluid/framework/ddim.h index 36ad90a2a..0d7b12120 100644 --- a/paddle/fluid/framework/ddim.h +++ b/paddle/fluid/framework/ddim.h @@ -136,12 +136,6 @@ class DDim { return *reinterpret_cast*>(p); } - // Construct DDim with given rank - // Only used in friend functions - explicit DDim(int rank) : rank_(rank) { - PADDLE_ENFORCE(rank_ >= 0 && rank_ < kMaxRank, "Invalid rank %d", rank); - } - friend DDim slice_ddim(const DDim& dim, int begin, int end); friend DDim stride(const DDim& ddim); friend DDim stride_numel(const DDim& ddim); -- GitLab