forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TVMC] Add composite target passes for compilation and tuning (apache…
…#7304) * Extend --target syntax to cover multiple targets for compilation and tuning * Add a new composite_target module to implement custom codegen passes into TVMC * Provide implementation to integrate TVMC, to target Arm Ethos-N NPU and Compute Library for the Arm Architecture (ACL) Change-Id: Iaee53fe22f0c14eb4e4c8ec47e72bade0c5e32cc
- Loading branch information
Showing
8 changed files
with
506 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,68 @@ | ||
# 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. | ||
""" | ||
Provides support to composite target on TVMC. | ||
""" | ||
import logging | ||
|
||
from tvm.relay.op.contrib.arm_compute_lib import partition_for_arm_compute_lib | ||
from tvm.relay.op.contrib.ethosn import partition_for_ethosn | ||
|
||
from .common import TVMCException | ||
|
||
|
||
# pylint: disable=invalid-name | ||
logger = logging.getLogger("TVMC") | ||
|
||
# Global dictionary to map targets with the configuration key | ||
# to be used in the PassContext (if any), and a function | ||
# responsible for partitioning to that target. | ||
REGISTERED_CODEGEN = { | ||
"acl": { | ||
"config_key": None, | ||
"pass_pipeline": partition_for_arm_compute_lib, | ||
}, | ||
"ethos-n77": { | ||
"config_key": "relay.ext.ethos-n.options", | ||
"pass_pipeline": partition_for_ethosn, | ||
}, | ||
} | ||
|
||
|
||
def get_codegen_names(): | ||
"""Return a list of all registered codegens. | ||
Returns | ||
------- | ||
list of str | ||
all registered targets | ||
""" | ||
return list(REGISTERED_CODEGEN.keys()) | ||
|
||
|
||
def get_codegen_by_target(name): | ||
"""Return a codegen entry by name. | ||
Returns | ||
------- | ||
dict | ||
requested target information | ||
""" | ||
try: | ||
return REGISTERED_CODEGEN[name] | ||
except KeyError: | ||
raise TVMCException("Composite target %s is not defined in TVMC." % name) |
Oops, something went wrong.