Skip to content

Commit 9812bb8

Browse files
committed
Fix pserver can NOT start with DebugString problem
1 parent 3185d38 commit 9812bb8

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

cmake/cudnn.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ list(APPEND CUDNN_CHECK_LIBRARY_DIRS
2121
${CUDNN_ROOT}/lib64
2222
${CUDNN_ROOT}/lib
2323
${CUDNN_ROOT}/lib/${TARGET_ARCH}-linux-gnu
24+
${CUDNN_ROOT}/local/cuda-8.0/targets/${TARGET_ARCH}-linux/lib/
2425
$ENV{CUDNN_ROOT}
2526
$ENV{CUDNN_ROOT}/lib64
2627
$ENV{CUDNN_ROOT}/lib

paddle/fluid/framework/operator.cc

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License. */
1818

1919
#include "paddle/fluid/framework/data_transform.h"
2020
#include "paddle/fluid/framework/executor.h"
21+
#include "paddle/fluid/framework/lod_tensor.h"
2122
#include "paddle/fluid/framework/operator.h"
2223
#include "paddle/fluid/framework/shape_inference.h"
2324
#include "paddle/fluid/framework/var_type.h"
@@ -56,13 +57,22 @@ static DDim GetDims(const Scope& scope, const std::string& name,
5657
return DDim({-1});
5758
}
5859

59-
if (var->IsType<LoDTensor>()) {
60-
return var->Get<LoDTensor>().dims();
61-
} else if (var->IsType<SelectedRows>()) {
62-
if (get_actual_dim) {
63-
return var->Get<SelectedRows>().value().dims();
60+
if (var->IsInitialized()) {
61+
if (var->IsType<LoDTensor>()) {
62+
const LoDTensor& tensor = var->Get<LoDTensor>();
63+
if (tensor.IsInitialized()) {
64+
return tensor.dims();
65+
} else {
66+
return DDim({-1});
67+
}
68+
} else if (var->IsType<SelectedRows>()) {
69+
if (get_actual_dim) {
70+
return var->Get<SelectedRows>().value().dims();
71+
} else {
72+
return var->Get<SelectedRows>().GetCompleteDims();
73+
}
6474
} else {
65-
return var->Get<SelectedRows>().GetCompleteDims();
75+
return DDim({-1});
6676
}
6777
} else {
6878
return DDim({-1});
@@ -74,11 +84,21 @@ static std::string GetDtype(const Scope& scope, const std::string& name) {
7484
if (var == nullptr) {
7585
return "";
7686
}
77-
if (var->IsType<LoDTensor>()) {
78-
return DataTypeToString(ToDataType(var->Get<LoDTensor>().type()));
79-
} else if (var->IsType<SelectedRows>()) {
80-
return DataTypeToString(
81-
ToDataType(var->Get<SelectedRows>().value().type()));
87+
88+
if (var->IsInitialized()) {
89+
if (var->IsType<LoDTensor>()) {
90+
const LoDTensor& tensor = var->Get<LoDTensor>();
91+
if (tensor.IsInitialized()) {
92+
return DataTypeToString(ToDataType(tensor.type()));
93+
} else {
94+
return "";
95+
}
96+
} else if (var->IsType<SelectedRows>()) {
97+
return DataTypeToString(
98+
ToDataType(var->Get<SelectedRows>().value().type()));
99+
} else {
100+
return "";
101+
}
82102
} else {
83103
return "";
84104
}
@@ -90,8 +110,10 @@ static int GetRowSize(const Scope& scope, const std::string& name) {
90110
return -1;
91111
}
92112

93-
if (var->IsType<SelectedRows>()) {
94-
return var->Get<SelectedRows>().rows().size();
113+
if (var->IsInitialized()) {
114+
if (var->IsType<SelectedRows>()) {
115+
return var->Get<SelectedRows>().rows().size();
116+
}
95117
}
96118

97119
return -1;
@@ -105,8 +127,17 @@ static LoD GetLoD(const Scope& scope, const std::string& name) {
105127
return default_lod;
106128
}
107129

108-
if (var->IsType<LoDTensor>()) {
109-
return var->Get<LoDTensor>().lod();
130+
if (var->IsInitialized()) {
131+
if (var->IsType<LoDTensor>()) {
132+
const LoDTensor& tensor = var->Get<LoDTensor>();
133+
if (tensor.IsInitialized()) {
134+
return tensor.lod();
135+
} else {
136+
return default_lod;
137+
}
138+
} else {
139+
return default_lod;
140+
}
110141
} else {
111142
return default_lod;
112143
}

0 commit comments

Comments
 (0)