Save the graphs stored in the `cur_config` in JSON format, which can be loaded by the Model Explorer GUI. :param cur_config: ModelExplorerConfig containing the graph for visualization. :param file_name: Name of the JSON file for storage.
(cur_config: ModelExplorerConfig, file_name: str)
| 148 | |
| 149 | |
| 150 | def _save_model_as_json(cur_config: ModelExplorerConfig, file_name: str): |
| 151 | """Save the graphs stored in the `cur_config` in JSON format, which can be loaded by the Model Explorer GUI. |
| 152 | |
| 153 | :param cur_config: ModelExplorerConfig containing the graph for visualization. |
| 154 | :param file_name: Name of the JSON file for storage. |
| 155 | """ |
| 156 | # Extract the graphs from the config file. |
| 157 | graphs_list = json.loads(cur_config.get_transferrable_data()["graphs_list"]) |
| 158 | graphs = json.loads(graphs_list[0])["graphs"] |
| 159 | |
| 160 | # The returned dictionary is missing the `collectionLabel` entry. Add it manually. |
| 161 | for graph in graphs: |
| 162 | graph["collectionLabel"] = "Executorch" |
| 163 | |
| 164 | # Create the JSON according to the structure required by the Model Explorer GUI. |
| 165 | json_data = { |
| 166 | "label": "Executorch", |
| 167 | "graphs": graphs, |
| 168 | "graphsWithLevel": [ |
| 169 | {"graph": graph, "level": level} for level, graph in enumerate(graphs) |
| 170 | ], |
| 171 | } |
| 172 | |
| 173 | # Store the JSON. |
| 174 | with open(file_name, "w") as f: |
| 175 | json.dump(json_data, f) |
| 176 | |
| 177 | |
| 178 | def visualize_with_clusters( |
no test coverage detected