ONE icon indicating copy to clipboard operation
ONE copied to clipboard

[tools] Enhance tflite tools

Open YongseopKim opened this issue 3 years ago • 5 comments

There are some utils on tools for tflite models. But, I'd like to add some features like

  • print graph on console
  • make tools ease searching/finding
  • show available constant values like slide_slice

After concrete goals, I'll make new issues separately.

/cc @chunseoklee @hseok-oh

YongseopKim avatar Dec 03 '21 01:12 YongseopKim

(as-is) tflitefile_tool -> (to-be) model_tool

  • the only tflite supports now
  • other model types support in the future

tflitefile_tool revised

  • modules: IR, parser, [text|graph|value]printer, saver, finder, ...

todos

  • [x] Arrange modules
  • [x] Separate model_parser from tflite

YongseopKim avatar Dec 06 '21 11:12 YongseopKim

as-is

~/Works/ONE/tools/tflitefile_tool(pr/tools/arrange_tflitefile_tool ✗) tree -L 2
.
├── ir
│   ├── graph_stats.py
│   ├── __init__.py
│   ├── operator_wrapping.py
│   └── tensor_wrapping.py
├── model_parser.py
├── parser
│   ├── __init__.py
│   ├── model_parser.py
│   └── operator_parser.py
├── printer
│   ├── __init__.py
│   ├── operator_printer.py
│   ├── option_printer.py
│   ├── subgraph_printer.py
│   └── tensor_printer.py
├── README.md
├── requirements.txt
├── saver
│   ├── config_saver.py
│   ├── __init__.py
│   └── model_saver.py
├── select_operator.py
└── tflite
    ├── AbsOptions.py
    ├── ...

to-be

~/Works/ONE/tools/tflitefile_tool(pr/tools/arrange_tflitefile_tool ✗) tree -L 2
.
├── ir
│   ├── model
│   ├── subgraph
│   ├── operator
│   ├── option
│   └── tensor; +const value
├── main.py
├── parser
│   ├── tflite_parser.py; inherits to below functions by tflite API
│   ├── other_parser.py; inherits to below functions by other API
│   ├── model_parser.py
│   ├── sungraph_parser.py
│   ├── tensor_parser.py
│   └── operator_parser.py
├── printer
│   ├── printer.py; below functions inherent to this function
│   ├── stdout_printer.py
│   ├── csv_printer.py
│   ├── dot_printer.py
│   └── graph_printer.py; this would be quite difficult
├── README.md
├── requirements.txt
├── saver
│   ├── config_saver.py
│   └── model_saver.py
├── select_operator.py
└── tflite
    ├── AbsOptions.py
    ├── ...

YongseopKim avatar Dec 08 '21 01:12 YongseopKim

https://github.com/Samsung/ONE/pull/8163

LGTM

@YongseopKim We may need unittest for better review.

Let's support unittest.

YongseopKim avatar Dec 13 '21 05:12 YongseopKim

After chatting with @mhs4670go , I figure out the necessity of what the final goal is.

  • tflitefile_tools could be nn model tools -> could support other types of nn models that use python apis
  • ascii graph printing could be a kind of diff tool -> could show the diff of nodes or attributes of nodes
  • could support features easily like search, save(multiple save file types), and so on.

YongseopKim avatar Dec 13 '21 08:12 YongseopKim

printer

  • [ ] remove saver/
  • [ ] introduce csv, dot printer

features

  • [ ] introduce printing buffer
  • [ ] introduce search(or find)

...

  • [ ] OpTypesCount -> from collections import Counter
  • [ ] Adds negative tests

https://github.com/Samsung/ONE/pull/8187 @hseok-oh

It's better to add negative test later.

YongseopKim avatar Dec 23 '21 03:12 YongseopKim