forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate passes to Pass Infra (apache#37)
* Migrate relax passes -> Pass infra. * Update. * Add docs and update tests. * Rebase and change namespace. * Address comments.
- Loading branch information
Showing
13 changed files
with
508 additions
and
173 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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/relax/backend.h | ||
* \brief Relax backend specific transformation passes. | ||
*/ | ||
#ifndef TVM_RELAX_BACKEND_H_ | ||
#define TVM_RELAX_BACKEND_H_ | ||
|
||
#include <tvm/relax/transform.h> | ||
|
||
namespace tvm { | ||
namespace relax { | ||
namespace transform { | ||
|
||
/*! | ||
* \brief Perform memory lowering. Lowers the relax.builtin.alloc_tensor intrinsic to VM intrinsics. | ||
* | ||
* \return The Pass. | ||
*/ | ||
TVM_DLL Pass VMMemoryLower(); | ||
|
||
/*! | ||
* \brief Lower the shape expression in relax to VM shape heap and TIR functions. | ||
* | ||
* \return The Pass. | ||
*/ | ||
TVM_DLL Pass VMShapeLower(); | ||
|
||
} // namespace transform | ||
} // namespace relax | ||
} // namespace tvm | ||
|
||
#endif // TVM_RELAX_BACKEND_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* 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/relax/transform.h | ||
* \brief Relax specific transformation passes. | ||
*/ | ||
#ifndef TVM_RELAX_TRANSFORM_H_ | ||
#define TVM_RELAX_TRANSFORM_H_ | ||
|
||
#include <tvm/ir/transform.h> | ||
#include <tvm/relax/expr.h> | ||
|
||
namespace tvm { | ||
namespace relax { | ||
namespace transform { | ||
|
||
using Pass = tvm::transform::Pass; | ||
using PassInfo = tvm::transform::PassInfo; | ||
using PassContext = tvm::transform::PassContext; | ||
using Function = tvm::relax::Function; | ||
|
||
/*! | ||
* \brief Create a function pass. | ||
* | ||
* \param pass_func The packed function that contains the optimization. | ||
* \param opt_level The optimization level of the function pass. | ||
* \param name The name of the function pass. | ||
* \param required The list of the passes that the function pass is dependent on. | ||
* | ||
* \return The created function pass. | ||
*/ | ||
TVM_DLL Pass CreateFunctionPass( | ||
const runtime::TypedPackedFunc<Function(Function, IRModule, PassContext)>& pass_func, | ||
int opt_level, String name, tvm::Array<String> required); | ||
|
||
/*! | ||
* \brief Perform fused multiply add rewriting in dataflow blocks. | ||
* | ||
* \return The Pass. | ||
*/ | ||
TVM_DLL Pass FMARewrite(); | ||
|
||
/*! | ||
* \brief Transform all dataflow structure to non-dataflow version. | ||
* | ||
* \return The Pass. | ||
*/ | ||
TVM_DLL Pass ToNonDataflow(); | ||
|
||
/*! | ||
* \brief Perform explicit tensor allocation for call_dps. | ||
* | ||
* \return The Pass. | ||
*/ | ||
TVM_DLL Pass CallDPSRewrite(); | ||
|
||
/*! | ||
* \brief Transform Relax IR to A-normal form. | ||
* | ||
* \return The Pass. | ||
*/ | ||
TVM_DLL Pass ToANF(); | ||
|
||
} // namespace transform | ||
} // namespace relax | ||
} // namespace tvm | ||
|
||
#endif // TVM_RELAX_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
Oops, something went wrong.