Skip to content

Commit

Permalink
on_device annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghaohit committed Aug 3, 2020
1 parent b70a5fe commit e2eedb2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions python/tvm/relay/op/_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
register_broadcast_schedule("fast_exp")
register_broadcast_schedule("fast_tanh")
register_broadcast_schedule("fast_erf")
# a fake on_device schedule.
# this will not be used in actual computation as on_device will be removed during DeviceAnnotation pass
register_injective_schedule("on_device")


# zeros
Expand Down
8 changes: 7 additions & 1 deletion src/relay/op/annotation/annotation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ RELAY_REGISTER_OP("on_device")
.add_type_rel("Identity", IdentityRel)
.set_attr<TOpPattern>("TOpPattern", kOpaque)
.set_attr<TOpIsStateful>("TOpIsStateful", false)
.set_attr<FInferCorrectLayout>("FInferCorrectLayout", ElemwiseArbitraryLayout);
.set_attr<FInferCorrectLayout>("FInferCorrectLayout", ElemwiseArbitraryLayout)
.set_attr<FTVMCompute>("FTVMCompute",
[] (const Attrs& attrs,
const Array<te::Tensor>& inputs,
const Type& out_type) -> Array<te::Tensor> {
return {topi::identity(inputs[0])};
});

Expr StopFusion(Expr data) {
static const Op& op = Op::Get("annotation.stop_fusion");
Expand Down

0 comments on commit e2eedb2

Please sign in to comment.