Skip to content

Commit 566c8a6

Browse files
committed
Improved node fill color choices
1 parent 4648803 commit 566c8a6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mlir/lib/Transforms/ViewOpGraph.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
124124
private:
125125
/// Generate a color mapping that will color every operation with the same
126126
/// name the same way. It'll interpolate the hue in the HSV color-space,
127-
/// attempting to keep the contrast suitable for black text.
127+
/// using muted colors that provide good contrast for black text.
128128
template <typename T>
129129
void initColorMapping(T &irEntity) {
130130
backgroundColors.clear();
@@ -137,8 +137,10 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
137137
});
138138
for (auto indexedOps : llvm::enumerate(ops)) {
139139
double hue = ((double)indexedOps.index()) / ops.size();
140+
// Use lower saturation (0.3) and higher value (0.95) for better
141+
// readability
140142
backgroundColors[indexedOps.value()->getName()].second =
141-
std::to_string(hue) + " 1.0 1.0";
143+
std::to_string(hue) + " 0.3 0.95";
142144
}
143145
}
144146

@@ -263,7 +265,7 @@ class PrintOpPass : public impl::ViewOpGraphBase<PrintOpPass> {
263265
attrs["shape"] = shape.str();
264266
if (!background.empty()) {
265267
attrs["style"] = "filled";
266-
attrs["fillcolor"] = ("\"" + background + "\"").str();
268+
attrs["fillcolor"] = quoteString(background.str());
267269
}
268270
os << llvm::format("v%i ", nodeId);
269271
emitAttrList(os, attrs);

0 commit comments

Comments
 (0)