-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[QNN][Relay] Calling Dialect passes from inside Relay Build API.
- Loading branch information
1 parent
4ba911a
commit fee4f73
Showing
10 changed files
with
178 additions
and
34 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
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. | ||
*/ | ||
|
||
/*! | ||
* \file tvm/relay/qnn/transform.h | ||
* | ||
* This file implements a pass manager for QNN ops using Relay Pass manager. | ||
*/ | ||
#ifndef TVM_RELAY_QNN_TRANSFORM_H_ | ||
#define TVM_RELAY_QNN_TRANSFORM_H_ | ||
|
||
#include <tvm/runtime/c_runtime_api.h> | ||
#include <tvm/relay/transform.h> | ||
|
||
namespace tvm { | ||
namespace relay { | ||
|
||
using relay::transform::Pass; | ||
|
||
namespace qnn { | ||
namespace transform { | ||
|
||
/*! | ||
* \brief Legalizes a QNN expr. Contains specifically two types of Legalizations. First, | ||
* converts/Lowers an expression containing QNN ops to an expression containing only core Relay ops. | ||
* Each QNN op is lowered to a sequence of exisiting Relay ops. This is a target-independent pass. | ||
* One can register the lowering/transformation function for this op using FTVMQnnCanonicalize | ||
* attr_name for FTVMLegalize op attribute. Second, as opposed to Relay Legalize, this one legalizes | ||
* only QNN ops. One can register a transformation/legalization function for an op by using the | ||
* FTVMQnnLegalize attr_name for FTVMLegalize op attribute. The isolation of QNN and Relay Legalize | ||
* gives us separation of concerns, leading to a better software practice. The legalization can be | ||
* configured to happen per target. | ||
* | ||
* \return The pass. | ||
*/ | ||
TVM_DLL Pass Legalize(); | ||
|
||
} // namespace transform | ||
|
||
} // namespace qnn | ||
} // namespace relay | ||
} // namespace tvm | ||
|
||
#endif // TVM_RELAY_QNN_TRANSFORM_H_ |
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,47 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/*! | ||
* \file relay/qnn/pass/legalize.cc | ||
* \brief The Legalize wrapper for QNN. | ||
*/ | ||
|
||
#include <tvm/relay/qnn/transform.h> | ||
|
||
namespace tvm { | ||
namespace relay { | ||
namespace qnn { | ||
|
||
namespace transform { | ||
|
||
Pass Legalize() { | ||
Array<Pass> pass_seqs; | ||
pass_seqs.push_back(relay::transform::Legalize("FTVMQnnLegalize")); | ||
pass_seqs.push_back(relay::transform::Legalize("FTVMQnnCanonicalize")); | ||
relay::transform::Pass seq = relay::transform::Sequential(pass_seqs); | ||
return seq; | ||
} | ||
|
||
TVM_REGISTER_API("relay.qnn._transform.Legalize").set_body_typed(Legalize); | ||
|
||
} // namespace transform | ||
|
||
} // namespace qnn | ||
} // namespace relay | ||
} // namespace tvm |
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