From 7f6e513b1fa798745d7cb918bd7a56d66607aed3 Mon Sep 17 00:00:00 2001 From: sneaxiy Date: Thu, 20 Dec 2018 12:21:51 +0000 Subject: [PATCH] fix mac ci bug make forward declaration test=develop --- paddle/fluid/framework/var_type_traits.cc | 13 ++++++ paddle/fluid/framework/var_type_traits.h | 43 +++++++++++++++---- .../fluid/framework/var_type_traits_test.cc | 31 +++++++------ 3 files changed, 64 insertions(+), 23 deletions(-) diff --git a/paddle/fluid/framework/var_type_traits.cc b/paddle/fluid/framework/var_type_traits.cc index 690c4895c1d..c3c5bab23b9 100644 --- a/paddle/fluid/framework/var_type_traits.cc +++ b/paddle/fluid/framework/var_type_traits.cc @@ -13,7 +13,20 @@ // limitations under the License. #include "paddle/fluid/framework/var_type_traits.h" +#include "paddle/fluid/framework/lod_rank_table.h" +#include "paddle/fluid/framework/reader.h" +#include "paddle/fluid/framework/scope.h" +#include "paddle/fluid/framework/selected_rows.h" +#include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h" #include "paddle/fluid/platform/macros.h" +#ifdef PADDLE_WITH_CUDA +#ifndef _WIN32 +#include "paddle/fluid/operators/nccl/nccl_gpu_common.h" +#endif +#include +#include "paddle/fluid/operators/conv_cudnn_op_cache.h" +#include "paddle/fluid/operators/cudnn_rnn_cache.h" +#endif namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/var_type_traits.h b/paddle/fluid/framework/var_type_traits.h index a58414c3d4e..b51b4933e6c 100644 --- a/paddle/fluid/framework/var_type_traits.h +++ b/paddle/fluid/framework/var_type_traits.h @@ -20,23 +20,48 @@ #include #include #include "paddle/fluid/framework/framework.pb.h" -#include "paddle/fluid/framework/lod_rank_table.h" #include "paddle/fluid/framework/lod_tensor_array.h" -#include "paddle/fluid/framework/reader.h" -#include "paddle/fluid/framework/selected_rows.h" -#include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h" -#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/place.h" #ifdef PADDLE_WITH_CUDA +#include #ifndef _WIN32 #include -#include "paddle/fluid/operators/nccl/nccl_gpu_common.h" #endif -#include -#include "paddle/fluid/operators/conv_cudnn_op_cache.h" -#include "paddle/fluid/operators/cudnn_rnn_cache.h" #endif +// Users should add forward declarations here +namespace paddle { + +namespace platform { +#ifdef PADDLE_WITH_CUDA +#ifndef _WIN32 +class Communicator; +#endif +#endif +} // namespace platform + +namespace framework { +class Tensor; +class LoDTensor; +class SelectedRows; +class LoDRankTable; +class ReaderHolder; +class Scope; +} // namespace framework + +namespace operators { +template +class AlgorithmsCache; + +class CudnnRNNCache; + +namespace reader { +class LoDTensorBlockingQueueHolder; +} // namespace reader +} // namespace operators + +} // namespace paddle + namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/var_type_traits_test.cc b/paddle/fluid/framework/var_type_traits_test.cc index 4dad4cb27b7..1c7d9f2abed 100644 --- a/paddle/fluid/framework/var_type_traits_test.cc +++ b/paddle/fluid/framework/var_type_traits_test.cc @@ -12,12 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/var_type_traits.h" #include #include #include #include +#include "paddle/fluid/framework/lod_rank_table.h" +#include "paddle/fluid/framework/reader.h" +#include "paddle/fluid/framework/scope.h" +#include "paddle/fluid/framework/selected_rows.h" +#include "paddle/fluid/framework/var_type_traits.h" +#include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h" +#ifdef PADDLE_WITH_CUDA +#ifndef _WIN32 +#include "paddle/fluid/operators/nccl/nccl_gpu_common.h" +#endif +#include "paddle/fluid/operators/conv_cudnn_op_cache.h" +#include "paddle/fluid/operators/cudnn_rnn_cache.h" +#endif + namespace paddle { namespace framework { @@ -32,19 +45,9 @@ struct TypeIndexChecker { constexpr auto kId = VarTypeTrait::kId; std::type_index actual_type(typeid(Type)); EXPECT_EQ(std::string(ToTypeName(kId)), std::string(actual_type.name())); - // For some reasons, comparing std::type_index using EXPECT_EQ would fail - // in MAC CI - bool is_same_type_index = (ToTypeIndex(kId) == actual_type); - if (!is_same_type_index) { - std::string s1 = ToTypeName(kId); - std::string s2 = actual_type.name(); - PADDLE_THROW("Step %d: type %s is not the same as %s, var_id %d", kPos, - s1.c_str(), s2.c_str(), kId); - } - EXPECT_TRUE(is_same_type_index); - EXPECT_TRUE(ToTypeId(actual_type) == kId); // NOLINT - is_same_type_index = (ToTypeIndex(ToTypeId(actual_type)) == actual_type); - EXPECT_TRUE(is_same_type_index); + EXPECT_EQ(ToTypeIndex(kId), actual_type); + EXPECT_EQ(ToTypeId(actual_type), kId); + EXPECT_EQ(ToTypeIndex(ToTypeId(actual_type)), actual_type); EXPECT_EQ(ToTypeId(ToTypeIndex(kId)), kId); EXPECT_TRUE(var_id_set->count(kId) == 0); // NOLINT -- GitLab