ONE icon indicating copy to clipboard operation
ONE copied to clipboard

[one-cmds] Introduce an one-cmd to make a init config file

Open YongseopKim opened this issue 3 years ago • 21 comments

As we discussed, let's introduce an one-cmd to make an init(or a default) config file. The name could be something like one-config-init or one-init.

YongseopKim avatar May 20 '22 09:05 YongseopKim

one-config-init init.cfg

how about one-new my-new-project.cfg ? or maybe just one-new my-new-project without .cfg

seanshpark avatar May 20 '22 09:05 seanshpark

one-new is also a good name!

And, I'll handle the file name like below

  1. if with .cfg, the file name is as-is
  2. if without .cfg, the file name also has .cfg as ext.

YongseopKim avatar May 20 '22 09:05 YongseopKim

one-new is also a good name!

Thanks :) one-init is also good (npm uses init, git uses init ...)

seanshpark avatar May 20 '22 10:05 seanshpark

Old Idea

The one-cmd takes the minimal options and makes a config file that contains the minimal content. The next step, and then, it would contain the default optimization options.

As I imagine,

$ one-config-init init.cfg --input_path='model.tflite' --output_path='new_model.file' --backend='npu'
...

$ ls
init.cfg

$ cat init.cfg
[onecc]
one-import-tflite=True # can get from model.tflite
one-optimize=True # we assume users want to make npu model as default
one-quantize=True
one-codegen=True

[one-import-tflite]
input_path=./model.tflite
output_path=./model.circle  # basename.circle

[one-optimize]
input_path=./model.circle
output_path=./model.opt.circle

[one-quantize]
input_path=./model.opt.circle
output_path=./model.q8.circle # basename.q.circle, q8 as default
granularity=channel # as default

[one-codegen]
backend=npu
command=-o new_model.file ./model.q8.circle

In the future,

[onecc]
one-import-tflite=True # can get from model.tflite
one-optimize=True # we assume users want to make npu model as default
one-quantize=True
one-codegen=True

[one-import-tflite]
input_path=./model.tflite
output_path=./model.circle  # basename.circle

[one-optimize]
input_path=./model.circle
output_path=./model.opt.circle
# if there are the default options
fuse_add_with_tconv=True
fold_add_v2=True
...=True

[one-quantize]
input_path=./model.opt.circle
output_path=./model.q8.circle # basename.q.circle, q8 as default
granularity=channel # as default

[one-codegen]
backend=npu
command=-o new_model.file ./model.q8.circle

YongseopKim avatar May 23 '22 07:05 YongseopKim

Okay, I decide to make the following

  1. the one-cmd name is one-init
  2. one-init just copies an existing cfg template that contains all false values and some commented values. You can imagine that bash and .bashrc style. We support all options commented and users can choose options by uncommenting them.
  3. onecc uses one-init by onecc init config.cfg

YongseopKim avatar May 23 '22 07:05 YongseopKim

And, in the future, we can support like one-config that adds or sets key/value for the config file.

YongseopKim avatar May 23 '22 07:05 YongseopKim

I'd like to revise one init and the default option (issue https://github.com/Samsung/ONE/issues/9191 pr https://github.com/Samsung/ONE/pull/9190).

After revising/discussing the idea and design, I'll leave new comments.

YongseopKim avatar Jun 07 '22 11:06 YongseopKim

one init ${model_name_wt_ext} -> makes a ${model_name}.cfg with default options for each model type that can be deduced by ext.

/cc @jyoungyun

YongseopKim avatar Jun 07 '22 11:06 YongseopKim

Q) from one init, is it typo of one-init or are you going to introduce one command with init sub command?

seanshpark avatar Jun 07 '22 22:06 seanshpark

It's a typo. one init -> onecc init so that one-init will be introduced.

YongseopKim avatar Jun 08 '22 01:06 YongseopKim

How about supporting two kinds of onecc init command?

onecc init : Create general template cfg file (including all import options) onecc init <model> : Create template cfg file according to model extension

This is a personal idea. :)

jyoungyun avatar Jun 08 '22 07:06 jyoungyun

(including all import options)

you mean one-import-tf=True and one-import-bcq=True, one-import-onnx=True ? and also one-import-tflite=True

seanshpark avatar Jun 08 '22 07:06 seanshpark

you mean one-import-tf=True and one-import-bcq=True, one-import-onnx=True ? and also one-import-tflite=True

Yes, but all import options will be False. The reason I suggested to show all import options is that user can choose what they want without worrying about the option name.

jyoungyun avatar Jun 09 '22 05:06 jyoungyun

@jyoungyun I think it's a great idea. I'll consider it.

YongseopKim avatar Jun 09 '22 05:06 YongseopKim

@jyoungyun , this is part of current onecc.template.cfg file, which I assume this file will be used to make initial .cfg file.

; To activate a step (or task),
; set True for the step in [onecc] section and fill options in the corresponding section
[onecc]
; neural network model to circle
one-import-tf=False
one-import-tflite=False
one-import-bcq=False
one-import-onnx=False
; circle to circle with optimization
one-optimize=False
; circle to circle with quantization
one-quantize=False
; partition circle
one-partition=False
; package circle and metadata into nnpackage
one-pack=False
; generate code for backend
one-codegen=False
; profile
one-profile=False

Is there some difference whay you want from? or your suggestion is about

onecc init : Create general template cfg file (including all import options)

which wasn't planned?

seanshpark avatar Jun 09 '22 07:06 seanshpark

I understood that onecc init : Create general template cfg file (including all import options) is copying onecc.template.cfg to new name. @jyoungyun right?

YongseopKim avatar Jun 09 '22 07:06 YongseopKim

My thoughts

  • onecc init: copy onecc.template.cfg to $CWD/init.cfg
  • onecc init model_name.ext
    • fail to parse ext: throw error
    • others: copy onecc.template.cfg to $CWD/model_name.cfg with some value change
      • example: https://github.com/Samsung/ONE/pull/9250
      • these files are being created by onecc init with copying the template cfg. (and that's why I revise the template file.)

YongseopKim avatar Jun 09 '22 07:06 YongseopKim

example: https://github.com/Samsung/ONE/pull/9250

I think it would be better to add some script or program to set default values, not adding new files for each initial .cfg files.

seanshpark avatar Jun 09 '22 07:06 seanshpark

I think it would be better to add some script or program to set default values, not adding new files for each initial .cfg files.

Yes, exactly. I wanted to show the results created by some scripts or programs. I'll introduce features within onecc init 😄 .

YongseopKim avatar Jun 09 '22 08:06 YongseopKim

I understood that onecc init : Create general template cfg file (including all import options) is copying onecc.template.cfg to new name. @jyoungyun right?

Yes, that's exactly what I want to say.

Is there some difference whay you want from? or your suggestion is about

onecc init : Create general template cfg file (including all import options)

which wasn't planned?

I mean that onecc init is copying onecc.template.cfg file. And I suggested that cfg file for each model does not exist separately, but the value of the existing template file (onecc.template.cfg) was modified according to the information of model file.

jyoungyun avatar Jun 10 '22 02:06 jyoungyun

Now I upload my draft(https://github.com/Samsung/ONE/pull/9259) according to your opinions.

YongseopKim avatar Jun 14 '22 02:06 YongseopKim