Skip to content

Commit

Permalink
Relax AST (apache#2)
Browse files Browse the repository at this point in the history
Co-authored-by: ZihengJiang <ziheng@apache.org>
  • Loading branch information
2 people authored and YuchenJin committed Mar 2, 2022
1 parent 27f4927 commit 25f8d83
Show file tree
Hide file tree
Showing 19 changed files with 1,185 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ tvm_file_glob(GLOB_RECURSE RELAY_IR_SRCS
tvm_file_glob(GLOB_RECURSE RELAY_QNN_SRCS
src/relay/qnn/*.cc
)

list(APPEND COMPILER_SRCS ${RELAY_OP_SRCS})
list(APPEND COMPILER_SRCS ${RELAY_PASS_SRCS})
list(APPEND COMPILER_SRCS ${RELAY_BACKEND_SRCS})
Expand Down
18 changes: 18 additions & 0 deletions include/tvm/ir/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class PrimExpr : public BaseExpr {
TVM_DLL static PrimExpr FromObject_(ObjectRef ref);
};

class RelayExpr;
/*!
* \brief Base node of all non-primitive expressions.
*
Expand All @@ -151,10 +152,27 @@ class RelayExprNode : public BaseExprNode {
* This value is discarded during serialization.
*/
mutable Type checked_type_ = Type(nullptr);

/*!
* \brief Stores the result of static shape analysis.
*
* \note The value will be optional if a static shape can not be inferred.
* use .shape() instead to acesss an always defined shape expression.
*/
Optional<Array<PrimExpr>> shape_ = Optional<Array<PrimExpr>>();

/*!
* \return The checked_type
*/
inline const Type& checked_type() const;

/*!
* \return An expression which corresponds to the shape of the expression.
*
* Only valid when the expression's type is a Tensor.
*/
inline RelayExpr shape() const;

/*!
* \brief Check if the inferred(checked) type of the Expr
* is backed by a TTypeNode and return it.
Expand Down
4 changes: 2 additions & 2 deletions include/tvm/node/structural_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
/*!
* \file tvm/node/structural_equal.h
* \file tvm/node/structural_hash.h
* \brief Structural hash class.
*/
#ifndef TVM_NODE_STRUCTURAL_HASH_H_
Expand Down Expand Up @@ -174,7 +174,7 @@ class SHashReducer {
/*!
* \brief Push hash of key to the current sequence of hash values.
* \param key The key to be hashed.
* \note This function indicate key could contain var defintions.
* \note This function indicates key could contain variable defintions.
*/
void DefHash(const ObjectRef& key) const { return handler_->SHashReduce(key, true); }
/*!
Expand Down
Loading

0 comments on commit 25f8d83

Please sign in to comment.