From a4e489ee2b5a0924d013f8828031b159f84fc8d9 Mon Sep 17 00:00:00 2001 From: Jonghwa Lee Date: Wed, 20 Nov 2024 16:27:44 +0900 Subject: [PATCH] =?UTF-8?q?[tools/model=5Fexplorer=5Fcircle]=20Introduce?= =?UTF-8?q?=20circle=20adapter=20for=20model=20expl=E2=80=A6=20(#14320)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It adds the initial version of circle adapter for model explorer. It'll simply show a empty main graph when circle file is loaded. ONE-DCO-1.0-Signed-off-by: Jonghwa Lee --- tools/model_explorer_circle/.gitignore | 2 ++ tools/model_explorer_circle/README.md | 7 ++++ .../src/circle_adapter/main.py | 34 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tools/model_explorer_circle/.gitignore create mode 100644 tools/model_explorer_circle/README.md create mode 100644 tools/model_explorer_circle/src/circle_adapter/main.py diff --git a/tools/model_explorer_circle/.gitignore b/tools/model_explorer_circle/.gitignore new file mode 100644 index 00000000000..31a8789d950 --- /dev/null +++ b/tools/model_explorer_circle/.gitignore @@ -0,0 +1,2 @@ +venv +src/*.egg-info/ diff --git a/tools/model_explorer_circle/README.md b/tools/model_explorer_circle/README.md new file mode 100644 index 00000000000..7da12c0e891 --- /dev/null +++ b/tools/model_explorer_circle/README.md @@ -0,0 +1,7 @@ +# Circle adapter for Model Explorer + +Circle adapter is an extension adapter for displaying a Circle model in Model Explorer. + +* [Model Explorer](https://github.com/google-ai-edge/model-explorer) + * Visulization tool for various type of model graphs such as onnx, tflite, pt2 and mlir. + diff --git a/tools/model_explorer_circle/src/circle_adapter/main.py b/tools/model_explorer_circle/src/circle_adapter/main.py new file mode 100644 index 00000000000..0fd9f543120 --- /dev/null +++ b/tools/model_explorer_circle/src/circle_adapter/main.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Model Explorer adapter for Circle models.""" + +from typing import Dict +from model_explorer import Adapter, AdapterMetadata, ModelExplorerGraphs, graph_builder + + +class CircleAdapter(Adapter): + """Adapter class for Circle models.""" + metadata = AdapterMetadata(id='circle-adapter', + name='Circle adapter', + description='Circle adapter!', + fileExts=['circle']) + + def __init__(self): + super().__init__() + + def convert(self, model_path: str, settings: Dict) -> ModelExplorerGraphs: + graph = graph_builder.Graph(id='main') + return {'graphs': [graph]}