Skip to content

Commit

Permalink
checkin stmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Oct 23, 2016
1 parent cf0fc36 commit dac6b52
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 39 deletions.
5 changes: 5 additions & 0 deletions include/tvm/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@ enum DataType : int {
* \note kOtherNodes could mean more than one node type.
*/
enum NodeType {
// expr nodes
kVarNode,
kIntNode,
kFloatNode,
kUnaryOpNode,
kBinaryOpNode,
kReduceNode,
kTensorReadNode,
// stmt nodes
kStoreNode,
kForRangeNode,
kIfThenElseNode,
kOtherNodes
};

Expand Down
39 changes: 0 additions & 39 deletions include/tvm/codegen.h

This file was deleted.

73 changes: 73 additions & 0 deletions include/tvm/stmt_node.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*!
* Copyright (c) 2016 by Contributors
* \file stmt.h
* \brief Common data structure for codegen
*/
#ifndef TVM_STMT_NODE_H_
#define TVM_STMT_NODE_H_

namespace tvm {

struct StmtNode : public Node {
};

/*! \brief Store data into buffer */
struct StoreNode : public StmtNode {
/*! \brief the variable representing the buffer */
Var buffer;
/*! \brief the buffer offset */
Expr offset;
/*! \brief The source expression*/
Expr src;
/*! \brief constructor */
StoreNode() {
node_type_ = kStoreNode;
}
void VisitNodeRefFields(FNodeRefVisit fvisit) override {
fvisit("buffer", &buffer);
fvisit("offset", &offset);
fvisit("src", &src);
}
};

/*! \brief for loop in range */
struct ForRangeNode : public StmtNode {
/*! \brief loop variable */
Var loop_var;
/*! \brief The loop range */
Range range;
/*! \brief body of the loop */
Stmt body;
/*! \brief constructor */
ForRangeNode() {
node_type_ = kForRangeNode;
}
void VisitNodeRefFields(FNodeRefVisit fvisit) override {
fvisit("loop_var", &loop_var);
fvisit("range", &range);
fvisit("body", &body);
}
};

/*! \brief conditional expression */
struct IfThenElseNode : public StmtNode {
/*! \brief The condition */
Expr cond;
/*! \brief The statement in then */
Stmt then_body;
/*! \brief The statement in else */
Stmt else_body;
/*! \brief constructor */
IfThenElseNode() {
node_type_ = kIfThenElseNode;
}
void VisitNodeRefFields(FNodeRefVisit fvisit) override {
fvisit("cond", &cond);
fvisit("then_body", &then_body);
fvisit("else_body", &else_body);
}
};

} // namespace tvm

#endif // TVM_CODEGEN_H_

0 comments on commit dac6b52

Please sign in to comment.