Skip to content

Commit

Permalink
add document
Browse files Browse the repository at this point in the history
lint

lint

save

save

add more case

save

error

lint

lint

commit

do

lint

save

fix lint

wrap it back as func

lint

save

remove dead comment

fix style

fix lint

Update src/relay/pass/partial_eval.cc

Co-Authored-By: MarisaKirisame <[email protected]>

Update src/relay/pass/partial_eval.cc

Co-Authored-By: MarisaKirisame <[email protected]>

Update src/relay/pass/partial_eval.cc

Co-Authored-By: MarisaKirisame <[email protected]>

Update src/relay/pass/partial_eval.cc

Co-Authored-By: MarisaKirisame <[email protected]>

Update src/relay/pass/partial_eval.cc

Co-Authored-By: MarisaKirisame <[email protected]>

Update src/relay/pass/partial_eval.cc

Co-Authored-By: MarisaKirisame <[email protected]>

address review feedback

pe now handle freevar. as a result preserving function is now trivial.

test

add basic test, implement pretty printing for generic function

test

lint

fix segfault

save

save

do

test

fix another error

address comment

commit

save

address review feedback

add test for invalidate, fix error in lookup

rename cont to boduy

fix error and add regression test

Update src/relay/pass/partial_eval.cc

Co-Authored-By: MarisaKirisame <[email protected]>

fix error, add test case

fix lint

remove extra line

fix some error

pe

commit

save

save

save

save

save (pe/dce broken)

[DOCKER] Pin flatbuffers checkout to the last release tag (apache#2823). (apache#2879)

[Relay][Text Format] Reverse CallNode Print Order (apache#2882)

[NNPACK] Modernize test (apache#2868)

[Relay] Add list update to prelude (apache#2866)

Add missing sgx includes (apache#2878)

Fix setting up hints for getaddrinfo (apache#2872)

[ARITH] RewriteSimplifier: improved cmp simplification (apache#2851)

do (apache#2883)

[RELAY][Frontend][TF] decompile tf control flow (apache#2830)

* decompile tf control flow

* Add docs

* remove import relay

* move tests under tensorflow frontend

* minor fix

Enhance upsample operator to adapt onnx opset version 9 (apache#2840)

Use version invariant rustfmt (apache#2886)

[Relay][Op] Add group conv2d dispatch to topi function (apache#2870)

* [Relay][Op] Add group conv2d dispatch to topi function

* Rerun tests

[Apps] [howto_deploy] fix cxx-flags order and build directory (apache#2888)

fix prelu, now can use on 2d input and add one test (apache#2875)

Add dense schedules to __init__ for cpu (apache#2855)

* Add dense schedules to __init__ for cpu

* Add documentation for topi::shape

* Add additional imports to topi CPU __init__.

[TESTS] Improve script robustness (apache#2893)

A number of test scripts use the '|| exit 1' idiom.  This has two
issues, first process exit codes are defined to be in the range 0-255.
Second, more importantly, the idiom is fragile because it requires
that every possible failure point be explicitly coded.  This patch
removes the idiom in favour of "set -e" as used in the docker scripts
as a more robust mechanism to ensure that script failures are always
caught and propagated by default.

[Relay] Fix name of bias in testing.mlp (apache#2892)

winograd_nnpack (apache#2721)

[Relay] Fix Relay ARM CPU depthwise spatial pack schedule alter op layout issue. (apache#2861)

* Fix Relay ARM CPU spatial pack depthwise alter op layout issue.

* Update tune_relay_arm.py

[TESTS] Import script robustness (set -u) (apache#2896)

Adopt the "set -u" idiom from the docker scripts as a mechanism to
improve future robustness.

[DOCKER] Upgrade ci-cpu to latest v0.50 (apache#2901)

Allow linking against MKLML (apache#2902)

[COMMUNITY] ASF mentors (apache#2906)

[Relay] Allow converting keras.layers.Sequential (apache#2842)

* Allow converting keras.layers.Sequential

* Use existing new_var function

* Only update expr when missing

* Add test

[Relay] clean up hd, change tl (apache#2917)

Turn on USE_SORT by default (apache#2916)

[TEST] Cache test data (apache#2921)

Unified error handling in NNVM and Relay frontends (apache#2828)

add support for mxnet smooth_l1 (apache#2905)

[Relay] Add support for TupleGetItem in op fusion (apache#2914)

[Relay, TOPI]  Deformable conv2d (apache#2908)

* [Relay, TOPI] Add deformable conv2d

* Moved to op level2

* Fix lint

* Moved to level2 & bug fix

* Update comments

* Disabled flaky test of conv2d

TVM debugresult dump to Chrome Tracing (apache#2922)

[Relay] add test for second order ad (apache#2754)

* do second order

* add comment

* better name

* use tvm assert all close

* refire ci

Revert "[Relay] add test for second order ad (apache#2754)" (apache#2926)

This reverts commit f5ca991.

[Tutorial] Cache the test data in tutorial (apache#2923)

[AUTOTVM] Refactor measure build func (apache#2927)

Fix intersect of modular set (apache#2904)

Fix comment bugs and code style

[Relay, OpFusion] Fix handling TupleGetItem for nested tuples (apache#2929)

Consistent result of DetectLinearEquation() when an empy vars is passed (apache#2860)

[FRONTEND][ONNX] Some bug fixes and Shape operator fixed for relay. (apache#2850)

* [FRONTEND][ONNX] Some bug fixes and Shape operator fixed for relay.

* 	* test cases

* 	* ci error

Outdated renaming for flatten in ONNX converter (apache#2843)

[FRONTEND][TENSORFLOW] bug fix for tensorflow official slim models. (apache#2864)

* [FRONTEND][TENSORFLOW] bug fix for tensorflow official slim models.

* 	* review comments

Fix vcvtph2ps codegen (apache#2925)

Port changes

More fixes

save

save

Changes to schedules and mxnet importer

save

save

save

save

save

remove

remove

save

save
  • Loading branch information
MarisaKirisame committed Apr 16, 2019
1 parent 0634778 commit 6756b9c
Show file tree
Hide file tree
Showing 10 changed files with 518 additions and 144 deletions.
41 changes: 40 additions & 1 deletion include/tvm/relay/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,26 @@ class VarNode : public ExprNode {

RELAY_DEFINE_NODE_REF(Var, VarNode, Expr);

/*! \brief Hash Var by it's id.
* Different VarNode might has same vid, and they are considered to be the same var in such case.
* Use VarHash to hash Var by id.
*/
struct VarHash {
size_t operator()(const Var& v) const {
return v->vid.hash();
}
};

/*! \brief Compare Var by it's id.
* Different VarNode might has same vid, and they are considered to be the same var in such case.
* Use VarEqual to compare Var by id.
*/
struct VarEqual {
bool operator()(const Var& l, const Var& r) const {
return l->vid.get() == r->vid.get();
}
};

/*!
* \brief Global variable that leaves in the top-level module.
* This is used to enable recursive calls between function.
Expand Down Expand Up @@ -521,7 +541,7 @@ RELAY_DEFINE_NODE_REF(RefWrite, RefWriteNode, Expr);
* rewriting pass such as layout or type transformation.
*
* Subclass TempExprNode allows us to pattern match on
* specific kind TempExpr and use them for expression rewriting.
* specific kind of TempExpr and use them for expression rewriting.
*
* TempExpr should only be used within a pass,
*/
Expand All @@ -539,6 +559,25 @@ class TempExprNode : public ExprNode {

RELAY_DEFINE_NODE_REF(TempExpr, TempExprNode, Expr);

class Annotate;
class AnnotateNode : public ExprNode {
public:
Expr expr;
NodeRef annotation;
void VisitAttrs(tvm::AttrVisitor* v) final {
v->Visit("expr", &expr);
v->Visit("annotation", &annotation);
v->Visit("_checked_type_", &checked_type_);
}

TVM_DLL static Annotate make(Expr expr, NodeRef annotation);

static constexpr const char* _type_key = "relay.AnnotateNode";
TVM_DECLARE_NODE_TYPE_INFO(AnnotateNode, ExprNode);
};

RELAY_DEFINE_NODE_REF(Annotate, AnnotateNode, Expr);

// implementataions
inline const Type& ExprNode::checked_type() const {
CHECK(checked_type_.defined()) << "internal error: the type checker has "
Expand Down
4 changes: 4 additions & 0 deletions include/tvm/relay/expr_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class ExprFunctor<R(const Expr& n, Args...)> {
virtual R VisitExpr_(const RefWriteNode* op, Args... args) EXPR_FUNCTOR_DEFAULT;
virtual R VisitExpr_(const ConstructorNode* op, Args... args) EXPR_FUNCTOR_DEFAULT;
virtual R VisitExpr_(const MatchNode* op, Args... args) EXPR_FUNCTOR_DEFAULT;
virtual R VisitExpr_(const AnnotateNode* op, Args... args) EXPR_FUNCTOR_DEFAULT;
virtual R VisitExprDefault_(const Node* op, Args...) {
throw Error(std::string("Do not have a default for ") + op->type_key());
}
Expand All @@ -140,6 +141,7 @@ class ExprFunctor<R(const Expr& n, Args...)> {
RELAY_EXPR_FUNCTOR_DISPATCH(RefWriteNode);
RELAY_EXPR_FUNCTOR_DISPATCH(ConstructorNode);
RELAY_EXPR_FUNCTOR_DISPATCH(MatchNode);
RELAY_EXPR_FUNCTOR_DISPATCH(AnnotateNode);
return vtable;
}
};
Expand Down Expand Up @@ -170,6 +172,7 @@ class ExprVisitor
void VisitExpr_(const RefWriteNode* op) override;
void VisitExpr_(const ConstructorNode* op) override;
void VisitExpr_(const MatchNode* op) override;
void VisitExpr_(const AnnotateNode* op) override;
virtual void VisitType(const Type& t);
virtual void VisitClause(const Clause& c);
virtual void VisitPattern(const Pattern& c);
Expand Down Expand Up @@ -212,6 +215,7 @@ class ExprMutator
Expr VisitExpr_(const RefWriteNode* op) override;
Expr VisitExpr_(const ConstructorNode* op) override;
Expr VisitExpr_(const MatchNode* op) override;
Expr VisitExpr_(const AnnotateNode* op) override;

/*!
* \brief Used to visit the types inside of expressions.
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/relay/op/nn/_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def schedule_batch_matmul(attrs, outputs, target):
with target:
return topi.generic.schedule_batch_matmul(outputs)

reg.register_pattern("nn.batch_matmul", reg.OpPattern.OUT_ELEMWISE_FUSABLE)
reg.register_pattern("nn.batch_matmul", reg.OpPattern.OPAQUE)


# conv2d
Expand Down
15 changes: 13 additions & 2 deletions src/relay/ir/expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ TVM_REGISTER_API("relay._make.Call")

TVM_STATIC_IR_FUNCTOR_REGISTER(IRPrinter, vtable)
.set_dispatch<CallNode>([](const CallNode* node, tvm::IRPrinter* p) {
p->stream << "CallNode(" << node->op << ", " << node->args << ", "
<< node->attrs << ", " << node->type_args << ")";
p->stream << "CallNode(" << node->op << ")";
});

Let LetNode::make(Var var, Expr value, Expr body) {
Expand Down Expand Up @@ -349,5 +348,17 @@ TVM_REGISTER_API("relay._expr.TempExprRealize")
*ret = temp->Realize();
});

Annotate AnnotateNode::make(Expr expr, NodeRef annotation) {
NodePtr<AnnotateNode> n = make_node<AnnotateNode>();
n->expr = std::move(expr);
n->annotation = std::move(annotation);
return Annotate(n);
}

TVM_STATIC_IR_FUNCTOR_REGISTER(IRPrinter, vtable)
.set_dispatch<AnnotateNode>([](const AnnotateNode* node, tvm::IRPrinter* p) {
p->stream << "AnnotateNode(" << node->expr << ")";
});

} // namespace relay
} // namespace tvm
8 changes: 8 additions & 0 deletions src/relay/ir/expr_functor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ Pattern ExprMutator::VisitPattern(const Pattern& p) { return p; }

Type ExprMutator::VisitType(const Type& t) { return t; }

Expr ExprMutator::VisitExpr_(const AnnotateNode* op) {
return AnnotateNode::make(VisitExpr(op->expr), op->annotation);
}

void ExprVisitor::VisitExpr(const Expr& expr) {
auto it = visit_counter_.find(expr.get());
if (it != visit_counter_.end()) {
Expand Down Expand Up @@ -315,6 +319,10 @@ void ExprVisitor::VisitExpr_(const MatchNode* op) {
}
}

void ExprVisitor::VisitExpr_(const AnnotateNode* op) {
this->VisitExpr(op->expr);
}

void ExprVisitor::VisitClause(const Clause& op) {
this->VisitPattern(op->lhs);
this->VisitExpr(op->rhs);
Expand Down
1 change: 1 addition & 0 deletions src/relay/ir/type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ TVM_STATIC_IR_FUNCTOR_REGISTER(IRPrinter, vtable)
});

TypeCall TypeCallNode::make(Type func, tvm::Array<Type> args) {
CHECK(func.as<GlobalTypeVarNode>());
NodePtr<TypeCallNode> n = make_node<TypeCallNode>();
n->func = std::move(func);
n->args = std::move(args);
Expand Down
2 changes: 1 addition & 1 deletion src/relay/op/nn/nn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ bool BatchMatmulRel(const Array<Type>& types,
const auto* x = types[0].as<TensorTypeNode>();
const auto* y = types[1].as<TensorTypeNode>();
if (x == nullptr || y == nullptr) return false;
if (x->shape.size() != 3 || y->shape.size() != 3) return false;
CHECK (x->shape.size() == 3 && y->shape.size() == 3);
CHECK(reporter->AssertEQ(x->shape[0], y->shape[0]))
<< "BatchDot: batch dimension doesn't match, "
<< " x shape=" << x->shape
Expand Down
14 changes: 12 additions & 2 deletions src/relay/op/tensor/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,19 @@ bool TakeRel(const Array<Type>& types,
// `types` contains: [data, indices, result]
CHECK_EQ(types.size(), 3);
const auto* data = types[0].as<TensorTypeNode>();
CHECK(data != nullptr);
if (data == nullptr) {
CHECK(types[0].as<IncompleteTypeNode>())
<< "must be tensor type or incomplete type";
return false;
}

const auto* indices = types[1].as<TensorTypeNode>();
CHECK(indices != nullptr);
if (indices == nullptr) {
CHECK(types[1].as<IncompleteTypeNode>())
<< "must be tensor type or incomplete type";
return true;
}

const auto param = attrs.as<TakeAttrs>();
CHECK(param != nullptr);

Expand Down
Loading

0 comments on commit 6756b9c

Please sign in to comment.