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.
[REFACTOR][ARITH] Unified IR, introduce arith subfolder. (apache#4722)
Spread the arithmetic.h into several components and move into arith subfolder. The arith namespace will be used for arithmetic expression pattern detections and simplifications.
- Loading branch information
Showing
63 changed files
with
483 additions
and
357 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* 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/arith/bound.h | ||
* \brief Bound deducers. | ||
*/ | ||
#ifndef TVM_ARITH_BOUND_H_ | ||
#define TVM_ARITH_BOUND_H_ | ||
|
||
#include <tvm/node/container.h> | ||
#include <tvm/ir/expr.h> | ||
#include <tvm/arith/int_set.h> | ||
#include <tvm/expr.h> | ||
|
||
#include <unordered_map> | ||
|
||
namespace tvm { | ||
// forward delcare Tensor | ||
class Tensor; | ||
namespace arith { | ||
|
||
/*! | ||
* \brief Deduce the bound of the target variable in a expression, | ||
* give the domain of each variables. Return undefined IntSet to | ||
* represent failure. | ||
* | ||
* \note The returned set may be smaller than set that | ||
* contains all possible values of v that satisfies the bound. | ||
* | ||
* \param v The target variable to be deduced. | ||
* \param cond The conditional expression. | ||
* \param hint_map The domain of variable, used to help deduce. | ||
* \param relax_map The domain of each variable, used to relax the domain, | ||
* The deduce bound must implies e for all value in relax_map | ||
* \return An integer set that always satisfies the condition. | ||
*/ | ||
IntSet DeduceBound(PrimExpr v, PrimExpr cond, | ||
const Map<Var, IntSet>& hint_map, | ||
const Map<Var, IntSet>& relax_map); | ||
/*! | ||
* \brief Same as DeduceBound with unordered_map signature. | ||
* | ||
* \param v The target variable to be deduced. | ||
* \param cond The conditional expression. | ||
* \param hint_map The domain of variable, used to help deduce. | ||
* \param relax_map The domain of each variable, used to relax the domain, | ||
* The deduce bound mush implies e for all value in relax_map | ||
* \return An integer set that always satisfies the condition. | ||
*/ | ||
IntSet DeduceBound(PrimExpr v, PrimExpr cond, | ||
const std::unordered_map<const VarNode*, IntSet>& hint_map, | ||
const std::unordered_map<const VarNode*, IntSet>& relax_map); | ||
|
||
/*! | ||
* \brief Infer a regular domain that covers all the calls or provides within the given statement. | ||
* \param body The given statement. | ||
* \param tensor The name of the calls or provides. | ||
* \param consider_calls If calls (read) are considered. | ||
* \param consider_provides If provides (write) are considered. | ||
* \return The domain that covers all the calls or provides within the given statement. | ||
*/ | ||
Domain DomainTouched(Stmt body, const Tensor &tensor, bool consider_calls, bool consider_provides); | ||
|
||
} // namespace arith | ||
} // namespace tvm | ||
#endif // TVM_ARITH_BOUND_H_ |
Oops, something went wrong.