Skip to content

Commit a5d68da

Browse files
jroeschZihengJiang
authored andcommitted
Relax AST (#2)
Co-authored-by: ZihengJiang <ziheng@apache.org>
1 parent 6930c0d commit a5d68da

File tree

19 files changed

+1185
-7
lines changed

19 files changed

+1185
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ tvm_file_glob(GLOB_RECURSE RELAY_IR_SRCS
313313
tvm_file_glob(GLOB_RECURSE RELAY_QNN_SRCS
314314
src/relay/qnn/*.cc
315315
)
316+
316317
list(APPEND COMPILER_SRCS ${RELAY_OP_SRCS})
317318
list(APPEND COMPILER_SRCS ${RELAY_PASS_SRCS})
318319
list(APPEND COMPILER_SRCS ${RELAY_BACKEND_SRCS})

include/tvm/ir/expr.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class PrimExpr : public BaseExpr {
133133
TVM_DLL static PrimExpr FromObject_(ObjectRef ref);
134134
};
135135

136+
class RelayExpr;
136137
/*!
137138
* \brief add operator
138139
*
@@ -365,10 +366,27 @@ class RelayExprNode : public BaseExprNode {
365366
* This value is discarded during serialization.
366367
*/
367368
mutable Type checked_type_ = Type(nullptr);
369+
370+
/*!
371+
* \brief Stores the result of static shape analysis.
372+
*
373+
* \note The value will be optional if a static shape can not be inferred.
374+
* use .shape() instead to acesss an always defined shape expression.
375+
*/
376+
Optional<Array<PrimExpr>> shape_ = Optional<Array<PrimExpr>>();
377+
368378
/*!
369379
* \return The checked_type
370380
*/
371381
inline const Type& checked_type() const;
382+
383+
/*!
384+
* \return An expression which corresponds to the shape of the expression.
385+
*
386+
* Only valid when the expression's type is a Tensor.
387+
*/
388+
inline RelayExpr shape() const;
389+
372390
/*!
373391
* \brief Check if the inferred(checked) type of the Expr
374392
* is backed by a TTypeNode and return it.

include/tvm/node/structural_hash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919
/*!
20-
* \file tvm/node/structural_equal.h
20+
* \file tvm/node/structural_hash.h
2121
* \brief Structural hash class.
2222
*/
2323
#ifndef TVM_NODE_STRUCTURAL_HASH_H_
@@ -174,7 +174,7 @@ class SHashReducer {
174174
/*!
175175
* \brief Push hash of key to the current sequence of hash values.
176176
* \param key The key to be hashed.
177-
* \note This function indicate key could contain var defintions.
177+
* \note This function indicates key could contain variable defintions.
178178
*/
179179
void DefHash(const ObjectRef& key) const { return handler_->SHashReduce(key, true); }
180180
/*!

0 commit comments

Comments
 (0)