forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 11
完善 MACA 后端适配:CMake 校验、架构传递、contrib 入口与 Relax 外部库入口 #41
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
Open
Zhao-Shi-jie
wants to merge
4
commits into
MetaX-MACA:dev
Choose a base branch
from
Zhao-Shi-jie:mc_dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| """Compatibility wrapper for the MACA compiler helper.""" | ||
|
|
||
| from tvm.support import mxcc as _mxcc | ||
| from tvm.support.mxcc import * # pylint: disable=wildcard-import,unused-wildcard-import | ||
|
|
||
|
|
||
| def get_maca_arch(maca_path="/opt/maca"): | ||
| """Return the MACA architecture using the support module callback.""" | ||
| return _mxcc.get_maca_arch(maca_path) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| """Relax entry points for MACA external library offload.""" | ||
|
|
||
| from typing import Optional, Sequence, Tuple | ||
|
|
||
| from tvm.ir import IRModule | ||
|
|
||
| _SUPPORTED_LIBRARIES = ("mcblas", "mcdnn", "mcfft") | ||
|
|
||
|
|
||
| def supported_libraries() -> Tuple[str, ...]: | ||
| """Return MACA external libraries known by this frontend.""" | ||
| return _SUPPORTED_LIBRARIES | ||
|
|
||
|
|
||
| def _normalize_library(library: str) -> str: | ||
| library = library.lower() | ||
| if library not in _SUPPORTED_LIBRARIES: | ||
| supported = ", ".join(_SUPPORTED_LIBRARIES) | ||
| raise ValueError(f"Unknown MACA external library '{library}'. Supported libraries: {supported}") | ||
| return library | ||
|
|
||
|
|
||
| def is_available(library: Optional[str] = None) -> bool: | ||
| """Return whether MACA Relax external library offload is available.""" | ||
| if library is not None: | ||
| _normalize_library(library) | ||
| return False | ||
|
|
||
|
|
||
| def partition_for_maca(mod: IRModule, libraries: Optional[Sequence[str]] = None) -> IRModule: | ||
| """Partition a Relax module for MACA external libraries. | ||
|
|
||
| The public entry point is present so callers can reliably detect the feature. | ||
| The actual mcBLAS/mcDNN/mcFFT codegen and runtime integration are not present | ||
| in this tree yet, so invoking partitioning fails explicitly instead of later | ||
| surfacing as a missing module, missing global function, or silent no-op. | ||
| """ | ||
| if libraries is not None: | ||
| for library in libraries: | ||
| _normalize_library(library) | ||
| raise NotImplementedError( | ||
| "MACA Relax external library offload is not implemented. " | ||
| "Expected mcBLAS/mcDNN/mcFFT codegen and runtime integration are absent." | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在
python/tvm/contrib/mxcc.py中重新定义get_maca_arch是多余的,因为from tvm.support.mxcc import *已经导入并导出了具有完全相同签名和行为的get_maca_arch。此外,tvm.support.mxcc中的原始函数包含更详细的 docstring,而这里的重定义会覆盖并丢失这些详细的文档信息。建议移除多余的
_mxcc导入和get_maca_arch函数重定义,直接使用通配符导入即可简化该文件。