Skip to content

Commit 7ebef49

Browse files
committed
add row_size for selected rows in DebugStringEx
1 parent cdd55db commit 7ebef49

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

paddle/fluid/framework/operator.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ static DDim GetDims(const Scope& scope, const std::string& name,
6969
}
7070
}
7171

72+
static int GetRowSize(const Scope& scope, const std::string& name) {
73+
Variable* var = scope.FindVar(name);
74+
if (var == nullptr) {
75+
return -1;
76+
}
77+
78+
if (var->IsType<SelectedRows>()) {
79+
return var->Get<SelectedRows>().rows().size();
80+
}
81+
82+
return -1;
83+
}
84+
7285
static LoD GetLoD(const Scope& scope, const std::string& name) {
7386
Variable* var = scope.FindVar(name);
7487
auto default_lod = LoD({{}});
@@ -153,6 +166,10 @@ std::string OperatorBase::DebugStringEx(const Scope* scope) const {
153166
for (size_t i = 0; i < input.second.size(); ++i) {
154167
ss << input.second[i];
155168
if (scope) {
169+
int row_size = GetRowSize(*scope, input.second[i]);
170+
if (row_size >= 0) {
171+
ss << "[row_size=" << row_size << "]";
172+
}
156173
ss << "[" << GetDims(*scope, input.second[i], true) << "]";
157174
ss << "(" << GetLoD(*scope, input.second[i]) << ")";
158175
}
@@ -173,6 +190,10 @@ std::string OperatorBase::DebugStringEx(const Scope* scope) const {
173190
for (size_t i = 0; i < output.second.size(); ++i) {
174191
ss << output.second[i];
175192
if (scope) {
193+
int row_size = GetRowSize(*scope, output.second[i]);
194+
if (row_size >= 0) {
195+
ss << "[row_size=" << row_size << "]";
196+
}
176197
ss << "[" << GetDims(*scope, output.second[i], true) << "]";
177198
ss << "(" << GetLoD(*scope, output.second[i]) << ")";
178199
}

0 commit comments

Comments
 (0)