New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[one-cmds] Support command schema for one-codegen #12886
Comments
HowHow to support this feature? I'm thinking of a schema file for the command. Each backend users who want to use this feature write a schema about their arguments of the backend driver. Then, onecc would refer to that schema file and run the configuration file accordingly. There are two things we need to decide - where and schema format. WhereThere are few options.
I prefer the latter. FormatLet's investigate and cover it in the following comments. Backward probabilityRunning orderOne concern is how to apply this feature with currently supporting keys in the one-codegen section - I decided to follow the steps.
Configuration file specIf a schema file is introduced, The change looks like below. If [onecc]
one-import-tf=True
one-optimize=True
one-codegen=dummy,dummyV2
[one-import-tf]
# ..
[one-optimize]
# ..
[dummy]
input=onecc_054.opt.circle
output=onecc_054.tvn
[dummyV2]
input_file=onecc_054.opt.circle
out=dummy.bin |
Schema formatPython argument parserThis method is to have backend users write a function that returns the argument parser. # /usr/share/one/command/dummy.py
def command_schema():
parser = argparse.ArgumentParser()
parser.add_argument(
"-i",
"--input",
required=True,
help="provide a path to .circle model.",
)
parser.add_argument(
"-o",
"--output",
required=True,
help="provide a path to .tvn model.",
)
return parser Then, onecc calls get the argument parser from above function and check if the keys in the configuration are valid. It is convenient but users have to write a python script who only use c++ in the tools. INI[input]
type=string
description=provide a path to .circle model.
required=True
[output]
type=string
description=provide a path to .tvn model.
required=True json or yaml{
"input": {
"description": "provide a path to .circle model.",
"type": "string"
},
"output": {
"description": "provide a path to .tvn model.",
"type": "string"
}
"DSP_quota": {
"type": "string"
}
"required": [ "DSP_quota" ]
"positional": [ "input", "output" ]
} |
Question about the motivationJust out of curiosity, may I ask why you want do it “now”? :) Question about the scopeDo you target only Question about the detailsTBH I think I don't fully understand your suggestion yet 😢 IIUC, in the scenario you suggested, there should be two schemas and a converter as below.
It’d be helpful for me to understand what you suggest if you could provide a sample of a schema file for an "existing" onecc tool, e.g. “onecc quantize” command. AFAIK the python Please feel free to correct me if I understand something wrong! |
No specific reason. As you said, I thought that it would be more convenient to support upcoming(?) target configuration feature with this command schema feature.
I thought so in the first place. But, it would be better to think of such expansion as well when designing the detail.
It should be only one schema that users have to make. Let me show you the example with the case that you worried about. import argparse
parser = argparse.ArgumentParser()
parser.add_argument('input')
parser.add_argument(
"-o",
required=True,
)
parser.add_argument(
"--DSP-quota",
)
parser.add_argument(
"-Otraffic",
action='store_true',
)
args = parser.parse_args() Then, command line can be like below. $ python MyCommand.py -o ${OUTPUT} --DSP-quota ${QUOTA} -Otraffic ${INPUT} Of course there are some corner case where the commands of the backend driver can't match the |
Well, I think I'm still missing something :) Q1: Who's responsible for converting the former ( AFAIK the python wrappers like User Input[one-codegen]
output=onecc_048.tvn
input=inception_v3.onecc_048.circle
DSP_quota=64K
Otraffic=True Expected arguments for the backend
Q3: If what you suggested is possible, |
@ejjeong I leave the answers for the history.
It is onecc. It converts the user inputs to the backend tool's commands according to the given command schema.
This is a pseudo code that I'm thinking about. Accessing the
Technically speaking it is possible. But, we won't. Because, AFAIK,
|
What
Let's support a command schema feature for one-codegen.
Why
When we write a one-codegen section in the configuration file, below keys are required.
Then, onecc internally calls the backend driver as if running the below commands in the bash. And, these work well.
But, actually, this kind of style doesn't match a bit with the styles of the other
one-cmds
tools. It would be like below if we make it get matched.So, what I'm trying to achieve in this issue is to give a chance to match the style to the backend users. Moreover, it would be easier for the backend tools to collaborate with the other
one-cmds
tools later.The text was updated successfully, but these errors were encountered: