Skip to content

Conversation

@Mousius
Copy link
Member

@Mousius Mousius commented Aug 16, 2022

This implements an initial Target Parser which aims to consolidate architecture feature detection from a few different places:

  • def get_arch_version(target_mattr):
    """Parse the LLVM target -mattr, and return
    the architecture version in a decimal representation
    (e.g., if -mattr=v8.4a, return 8.4)
    """
    arch_version = 8.0
    m = re.compile(r"\+v(.*)\.(.*)a")
    for attr in target_mattr:
    match_obj = m.match(attr)
    if match_obj:
    major = int(match_obj.group(1))
    minor = int(match_obj.group(2))
    decimal = 10
    if minor >= 10:
    decimal = 100
    arch_version = major + float(minor) / decimal
    return arch_version
    def is_dotprod_available():
    """Checks whether the hardware has support for udot/sdot instructions."""
    target = tvm.target.Target.current(allow_none=False)
    arch_version = get_arch_version(target.mattr)
    return arch_version >= 8.4 or ((arch_version in (8.2, 8.3)) and "+dotprod" in target.mattr)
    def is_mmla_available():
    """Checks whether the hardware has support for ummla/smmla instructions."""
    target = tvm.target.Target.current(allow_none=False)
    arch_version = get_arch_version(target.mattr)
    return arch_version >= 8.6 or (
    (arch_version in (8.2, 8.3, 8.4, 8.5)) and "+i8mm" in target.mattr
    )
    def is_aarch64_arm():
    """Checks whether we are compiling for an AArch64 target."""
    target = tvm.target.Target.current(allow_none=False)
    return "aarch64" in target.attrs.get("mtriple", "")
    def is_neon_available():
    """Check if neon instructions are available"""
    target = tvm.target.Target.current(allow_none=False)
    return "+neon" in target.mattr
  • def is_fast_int8_on_arm():
    """Checks whether the hardware has support for fast Int8 arithmetic operations."""
    target = tvm.target.Target.current(allow_none=False)
    return "+v8.2a" in target.mattr and "+dotprod" in target.mattr
    def is_aarch64_arm():
    """Checks whether we are compiling for an AArch64 target."""
    target = tvm.target.Target.current(allow_none=False)
    return "aarch64" in target.attrs.get("mtriple", "")
  • if is_aarch64 or "+neon" in target.mattr:

A further patch will remove all of the above and replace usages with the .features map.

@Mousius
Copy link
Member Author

Mousius commented Aug 16, 2022

cc @u99127 for review 😸

Mousius added a commit to Mousius/tvm that referenced this pull request Aug 16, 2022
Following on from apache#12454 this patch removes the utility functions in favour of the centralised `target.features` property.
Mousius added a commit to Mousius/tvm that referenced this pull request Aug 16, 2022
Following on from apache#12454 this patch removes the utility functions in favour of the centralised `target.features` property.
@Mousius Mousius force-pushed the target-parser-aprofile branch from a8f7ba2 to 2184d2e Compare August 16, 2022 13:41
Mousius added a commit to Mousius/tvm that referenced this pull request Aug 16, 2022
Following on from apache#12454 this patch removes the utility functions in favour of the centralised `target.features` property.
@Mousius Mousius force-pushed the target-parser-aprofile branch from 2184d2e to 29a3843 Compare August 16, 2022 16:09
Mousius added a commit to Mousius/tvm that referenced this pull request Aug 16, 2022
Following on from apache#12454 this patch removes the utility functions in favour of the centralised `target.features` property.
@github-actions
Copy link
Contributor

It has been a while since this PR was updated, @u99127 please leave a review or address the outstanding comments. @Mousius if this PR is still a work in progress, please convert it to a draft until it is ready for review.

@Mousius Mousius force-pushed the target-parser-aprofile branch from 29a3843 to 4ff0fc4 Compare August 25, 2022 09:45
Mousius added a commit to Mousius/tvm that referenced this pull request Aug 25, 2022
Following on from apache#12454 this patch removes the utility functions in favour of the centralised `target.features` property.
@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2022

It has been a while since this PR was updated, @u99127 please leave a review or address the outstanding comments. @Mousius if this PR is still a work in progress, please convert it to a draft until it is ready for review.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2022

It has been a while since this PR was updated, @u99127 please leave a review or address the outstanding comments. @Mousius if this PR is still a work in progress, please convert it to a draft until it is ready for review.

1 similar comment
@github-actions
Copy link
Contributor

It has been a while since this PR was updated, @u99127 please leave a review or address the outstanding comments. @Mousius if this PR is still a work in progress, please convert it to a draft until it is ready for review.

Copy link

@u99127 u99127 left a comment

Choose a reason for hiding this comment

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

Sorry about the time it has taken to get around to this :)

If I could request a few changes , then I'm good .

@Mousius Mousius force-pushed the target-parser-aprofile branch from 4ff0fc4 to 85ab2a3 Compare October 13, 2022 16:45
Mousius added a commit that referenced this pull request Oct 13, 2022
Following on from #12454 this patch removes the utility functions in favour of the centralised `target.features` property.
@areusch areusch added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it and removed needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it labels Oct 19, 2022
@tvm-bot
Copy link
Collaborator

tvm-bot commented Oct 19, 2022

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

Copy link

@u99127 u99127 left a comment

Choose a reason for hiding this comment

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

LGTM. Just watch out what you'd like in the commit message given the tree of commits here - I'm sure you already know this :)

Copy link
Contributor

@lhutton1 lhutton1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@Mousius Mousius merged commit 308c20a into apache:main Oct 20, 2022
@Mousius Mousius deleted the target-parser-aprofile branch October 20, 2022 09:24
Mousius added a commit to Mousius/tvm that referenced this pull request Oct 20, 2022
Following on from apache#12454 this patch removes the utility functions in favour of the centralised `target.features` property.
lhutton1 pushed a commit that referenced this pull request Oct 24, 2022
Following on from #12454 this patch removes the utility functions in favour of the centralised `target.features` property.
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 10, 2022
Following on from apache#12454 this patch removes the utility functions in favour of the centralised `target.features` property.
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
Following on from apache#12454 this patch removes the utility functions in favour of the centralised `target.features` property.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants