| 121 | } |
| 122 | |
| 123 | void GetArrayColorAndShape(const Model& model, const string& array_name, |
| 124 | Color* color, string* shape) { |
| 125 | // All colors in this file are from: |
| 126 | // https://material.io/guidelines/style/color.html |
| 127 | // Arrays involved in RNN back-edges have a different color |
| 128 | for (const auto& rnn_state : model.flags.rnn_states()) { |
| 129 | // RNN state, fed by a back-edge. Bold color. |
| 130 | if (array_name == rnn_state.state_array()) { |
| 131 | *color = Color(0x0F, 0x9D, 0x58); |
| 132 | *shape = "invhouse"; |
| 133 | return; |
| 134 | } |
| 135 | // RNN back-edge source, feeding a RNN state. |
| 136 | // Light tone of the same color as RNN states. |
| 137 | if (array_name == rnn_state.back_edge_source_array()) { |
| 138 | *color = Color(0xB7, 0xE1, 0xCD); |
| 139 | *shape = "house"; |
| 140 | return; |
| 141 | } |
| 142 | } |
| 143 | // Constant parameter arrays have their own bold color |
| 144 | if (model.GetArray(array_name).buffer) { |
| 145 | *color = Color(0x42, 0x85, 0xF4); |
| 146 | *shape = "cylinder"; |
| 147 | return; |
| 148 | } |
| 149 | // Remaining arrays are activations. |
| 150 | // We use gray colors for them because they are the majority |
| 151 | // of arrays so we want to highlight other arrays instead of them. |
| 152 | // First, we use a bolder gray for input/output arrays: |
| 153 | if (IsInputArray(model, array_name)) { |
| 154 | *color = Color(0x9E, 0x9E, 0x9E); |
| 155 | *shape = "invhouse"; |
| 156 | return; |
| 157 | } |
| 158 | if (IsOutputArray(model, array_name)) { |
| 159 | *color = Color(0x9E, 0x9E, 0x9E); |
| 160 | *shape = "house"; |
| 161 | return; |
| 162 | } |
| 163 | // Remaining arrays are intermediate activation arrays. |
| 164 | // Lighter tone of the same grey as for input/output arrays: |
| 165 | // We want these to be very discrete. |
| 166 | *color = Color(0xF5, 0xF5, 0xF5); |
| 167 | *shape = "box"; |
| 168 | } |
| 169 | |
| 170 | string GetArrayCompassPt(const Model& model, const string& array_name) { |
| 171 | // The "compass point" is the point on the node where edge connections are |
no test coverage detected