MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / DebugString

Function DebugString

paddle/fluid/imperative/layer.cc:82–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80
81template <typename VarType>
82static std::string DebugString(
83 const std::string& name,
84 const std::vector<std::shared_ptr<VarType>>& vars) {
85 std::stringstream ss;
86 ss << name << "{";
87
88 for (size_t i = 0; i < vars.size(); ++i) {
89 if (i > 0) ss << ", ";
90
91 if (vars[i] == nullptr) {
92 ss << "NULL";
93 continue;
94 }
95 ss << GetNameFromVar(vars[i]) << "[";
96 const framework::Variable& var = vars[i]->Var();
97 if (!var.IsInitialized()) {
98 ss << "NOT_INITED_VAR";
99 } else if (var.IsType<DenseTensor>()) {
100 auto& tensor = var.Get<DenseTensor>();
101 ss << "DenseTensor<";
102 if (tensor.IsInitialized()) {
103 ss << framework::DataTypeToString(
104 framework::TransToProtoVarType(tensor.dtype()))
105 << ", ";
106 ss << tensor.place() << ", ";
107 ss << "(" << tensor.dims() << ")";
108 } else {
109 ss << "NOT_INITED";
110 }
111 ss << ">";
112 } else if (var.IsType<phi::SelectedRows>()) {
113 ss << "SelectedRows<";
114 auto& selected_rows = var.Get<phi::SelectedRows>();
115 auto& tensor = selected_rows.value();
116 auto& rows = selected_rows.rows();
117 if (tensor.IsInitialized()) {
118 ss << framework::DataTypeToString(
119 framework::TransToProtoVarType(tensor.dtype()))
120 << ", ";
121 ss << tensor.place() << ", ";
122 ss << "height(" << selected_rows.height() << "), rows(";
123 std::for_each(rows.cbegin(), rows.cend(), [&ss](const int64_t r) {
124 ss << r << " ";
125 });
126 ss << "), dims(" << tensor.dims() << ")";
127 } else {
128 ss << "NOT_INITED";
129 }
130 ss << ">";
131 } else {
132 ss << "UNRESOLVED_TYPE";
133 }
134 ss << "]";
135 }
136
137 ss << "}";
138 return ss.str();
139}

Callers 15

operator()Method · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TESTFunction · 0.50
TestMainFunction · 0.50

Calls 14

for_eachFunction · 0.85
DataTypeToStringFunction · 0.50
TransToProtoVarTypeFunction · 0.50
sizeMethod · 0.45
VarMethod · 0.45
IsInitializedMethod · 0.45
dtypeMethod · 0.45
placeMethod · 0.45
dimsMethod · 0.45
valueMethod · 0.45
heightMethod · 0.45
cbeginMethod · 0.45

Tested by 15

TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40
TestMainFunction · 0.40
TESTFunction · 0.40