Mousius commented on a change in pull request #30:
URL: https://github.com/apache/tvm-rfcs/pull/30#discussion_r714014999



##########
File path: rfcs/0030-tvmc-comand-line-configuration-files.md
##########
@@ -0,0 +1,119 @@
+- Feature Name: Command Line Configuration Files
+- Start Date: 2021-08-09
+- RFC PR: [apache/tvm-rfcs#30](https://github.com/apache/tvm-rfcs/pull/30)
+- GitHub Issue: [apache/tvm#0000](https://github.com/apache/tvm/issues/0000)
+
+# Summary
+[summary]: #summary
+
+Collecting common configurations for users of TVM and exposing them gracefully 
in `tvmc` using a `--config` option.
+
+# Motivation
+[motivation]: #motivation
+
+When a user first approaches TVM, choosing an appropriate configuration can be 
difficult, this is increasingly true in embedded systems where the 
configuration is not only a collection of devices but also how those devices 
are interfaced (see [Arm® Corstone™-300 reference 
package](https://developer.arm.com/ip-products/subsystem/corstone/corstone-300)).
 Trying to specify all of this in a target string or via command line arguments 
would be error prone and tedious. Predefining these in a common format allows 
users to get started and take the configurations for their own use cases easily.
+
+# Guide-level explanation
+[guide-level-explanation]: #guide-level-explanation
+
+## TVM Hosted Configurations
+Configurations will be stored as [JSON5](https://json5.org/) at 
`configs/<TYPE>/<NAME>.json`, this top level directory will enable other 
tooling to load configurations just as easily a `tvmc` and provide easy sign 
posting for users looking for configurations.
+
+A user coming to `tvmc` will begin with a default configuration which sets 
sensible defaults, such that `tvmc compile my_model.tflite` works out of the 
box. This is enabled by a `configs/host/default.json` which is likely to 
specify:
+
+```
+{
+  targets: [
+    {
+      kind: "llvm"
+    }
+  ]
+}
+```
+
+As a more substantial example, you can imagine an embedded board configuration 
such as the [Arm&reg; Corstone&trade;-300 reference 
package](https://developer.arm.com/ip-products/subsystem/corstone/corstone-300),
 which would exist under `configs/boards/corstone-300.json`:
+
+```json
+{
+  "output_format": "mlf",
+  "executor": {
+    "kind": "aot",
+    "unpacked-api": true
+  },
+  "targets": [
+    {
+      "kind": "ethos-u",
+      "accelerator_config": "ethos-u55-32"
+    },
+    {
+      "kind": "cmsisnn",
+      "mattr": "+fp"
+    },
+    {
+      "kind": "llvm"
+    }
+  ]
+}
+```
+
+This would be used if the user simply specifies `--config=corstone-300`, as in 
the following example:
+```
+tvmc compile --config=corstone-300 my_model.tflite
+```
+
+## User Provided Configurations
+The default search path, as illustrated above, is to find a matching 
`<NAME>.json` to an argument `--config=<NAME>`. A user can instead specify a 
path in the `--config` argument such as:
+
+```bash
+--config=./my.json
+--config=/etc/devices/my_secret_board.json
+```
+
+By default, TVM will prefer files explicitly specified as a path instead of 
hosted files.
+
+## Combination with existing parameters
+In the case of `tvmc`, `--config` will work alongside other arguments. Ideally 
anything specifiable in JSON will be specifiable in the command line to allow 
users to make small alterations such as:
+
+```
+tvmc \
+  compile \
+  --config=corstone-300 \
+  --executor-aot-unpacked-api=0
+```
+
+Which allows experimentation with different parameters that can then be added 
to a custom JSON.
+
+# Reference-level explanation
+[reference-level-explanation]: #reference-level-explanation
+
+This will change the behaviour of how `tvmc` utilises `argparse`, it will 
first translate arguments from `argparse` into an internal dictionary of 
attributes and then apply those over the top of any specified configuration 
files. This means the default options for `argparse` are essentially nulled as 
they won't be aware of configuration files until after the arguments are 
parsed. The hierarchy is therefore:

Review comment:
       Added examples, essentially it just takes your new `Target` parameters 
and overrides the previous ones but keeping previous attrs.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to