Skip to content
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

[Target] Introduce Target Id Registry #5838

Merged
merged 3 commits into from Jun 20, 2020
Merged

[Target] Introduce Target Id Registry #5838

merged 3 commits into from Jun 20, 2020

Conversation

junrushao
Copy link
Member

@junrushao junrushao commented Jun 18, 2020

Per RFC TVM Target Specification.

We implemented a target id registry which supports the following syntax:

TVM_REGISTER_TARGET_ID("llvm")
.set_attr<TPreCodegenPass>("TPreCodegenPass", ...)
.add_attr_option<Bool>("system_lib")
.add_attr_option<String>("mtriple")
.add_attr_option<String>("mattr");

Copy link
Member

@tqchen tqchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have simple testcases around target id

include/tvm/target/target_id.h Outdated Show resolved Hide resolved
@tqchen
Copy link
Member

tqchen commented Jun 19, 2020

@junrushao1994 please rebase against the master

Copy link
Contributor

@ANSHUMAN87 ANSHUMAN87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@junrushao1994 : Thanks for the PR! Great work 👍

Please find some high level comments. Hope it is helpful. Thanks!

include/tvm/target/target_id.h Outdated Show resolved Hide resolved
include/tvm/target/target_id.h Show resolved Hide resolved
include/tvm/target/target_id.h Show resolved Hide resolved
include/tvm/target/target_id.h Outdated Show resolved Hide resolved
src/target/target_id.cc Outdated Show resolved Hide resolved
tests/cpp/target_test.cc Outdated Show resolved Hide resolved
include/tvm/target/target_id.h Show resolved Hide resolved
@junrushao
Copy link
Member Author

Thank you @ANSHUMAN87 for the review!

@junrushao
Copy link
Member Author

@tqchen could you take another look?

Changes

  • Added schema validation
  • Added several tests

src/target/target_id.cc Outdated Show resolved Hide resolved
src/target/target_id.cc Show resolved Hide resolved
@tqchen
Copy link
Member

tqchen commented Jun 19, 2020

Note about the second level validation:

{
    "id": "cuda",
    "tag": "nvidia/tx2-cudnn",
    "keys": ["cuda", "gpu"],
    "libs": ["cudnn"],
    "target_host": {
        "id": "llvm",
        "system_lib": True,
        "mtriple": "aarch64-linux-gnu",
        "mattr": "+neon"
    }
}

In the above example, the schema of cuda looks like

- keys: Array[str]
- target_host: Target

And we need to be able to validate the information in llvm. For example, if we add an invalid attribute to the target host map(that is not registered by llvm) it will trigger an error.

@junrushao
Copy link
Member Author

@tqchen As far as I could understand, we need validation twice, one for target, one for target_host.

Therefore, the step-by-step procedure should be:

  1. Let "target" map be the given map removing "target_host" entry
  2. Figure out the "id" entry in "target"
  3. Validate "target" using the TargetId indicated by "id"
  4. Validate "target_host" in the same way.

Is that correct?

BTW, why the schema of cuda doesn't include "libs" and "tag"?

@tqchen
Copy link
Member

tqchen commented Jun 19, 2020

Sorrt i omitted the libs and tags, they should be. Would be great if we can have a test example

@junrushao
Copy link
Member Author

@tqchen Just added support for target_host, and right now are can support validating the entire map directly via TargetValidateSchema

@tqchen
Copy link
Member

tqchen commented Jun 20, 2020

see some additional followups about making Target as part of the schema, to recognize perhaps Array<Target> and Target and do recursive handling.

@junrushao
Copy link
Member Author

Future work may include:

  1. Refactor the object TargetNode
  2. Allow Target to be a special type supported in schema validation, so that composite/recursive targets can be supported more naturally
  3. Support constructing TargetNode from JSON

@tqchen tqchen merged commit 2dcfd61 into apache:master Jun 20, 2020
@tqchen
Copy link
Member

tqchen commented Jun 20, 2020

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 30, 2020
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants