Samsung / ONE

On-device Neural Engine
Other
427 stars 151 forks source link

[one-cmds] Reivse utils.py #8169

Open mhs4670go opened 2 years ago

mhs4670go commented 2 years ago

What

Let's revise utils.py of one-cmds.

Why

As one-cmds gets matured, the size of utils.py is getting bigger. Now, utils is too ambiguous to know its purpose. So, I think it'd be better to split it into more specific ones for maintainability and readability.

This is what i think it is going to look like.

# AS-IS
$ tree
.
├── circle2circle
├── circledump
..
├── generate_bcq_metadata.py
├── generate_bcq_output_arrays.py
├── luci_eval_driver
..
├── tflite2circle
├── utils.py
└── venv/
# TO-BE
$ tree
.
├── circle2circle
├── circledump
..
├── python/
    ├── generate_bcq_metadata.py
    ├── generate_bcq_output_arrays.py
    ├── make_command.py
    ├── parse.py
    └── ..

Actually, other files could be moved to another single directory as well later. Then, one-cmds drivers would be remained at parent directory.

# TO-BE
$ tree
.
├── one-build
├── one-build.template.cfg
├── onecc
├── onecc.template.cfg
├── one-codegen
├── one-import
├── one-import-bcq
├── one-import-onnx
├── one-import-tf
├── one-import-tflite
├── one-optimize
├── one-pack
├── one-prepare-venv
├── one-profile
├── one-quantize
├── one-version
├── python/
│   ├── generate_bcq_metadata.py
│   ├── generate_bcq_output_arrays.py
│   ├── onnx_legalizer.py
│   ├── tf2tfliteV2.py
│   └── ..
├── scripts/
│   └── model2nnpkg.sh
├── tools/
│   ├── circle2circle
│   ├── circledump
│   ├── circle_partitioner
│   ├── circle-quantizer
│   ├── circle-tensordump
│   ├── luci_eval_driver
│   ├── rawdata2hdf5
│   ├── record-minmax
│   ├── tf2nnpkg
│   ├── tflchef
│   ├── tflchef-file
│   ├── tflchef-reverse
│   └── tflite2circle
└── venv/
seanshpark commented 2 years ago
├── python/
    ├── generate_bcq_metadata.py

why is the folder name python ?

mhs4670go commented 2 years ago

@seanshpark It can be better name. I just wrote it because there will be only python files. Just utils is came up with as a directory name.

seanshpark commented 2 years ago

how about helpers ?

seanshpark commented 2 years ago

I'm not sure about moving tool programs to tools folder..

├── tools/
│   ├── circle2circle
mhs4670go commented 2 years ago

@seanshpark

I'm not sure about moving tool programs to tools folder..

Then, let's leave it as it is.

how about helpers ?

Looks good to me, too. Except one thought: "helpers" could be even applied to other tools. Well, actually, naming is too hard here because things that they do are very different each other.. T_T

seanshpark commented 2 years ago

naming is too hard here because things that they do are very different each other.. T_T

I think python folder name is also OK as there will be python scripts for some specific purpose.