Mousius commented on a change in pull request #9077:
URL: https://github.com/apache/tvm/pull/9077#discussion_r715444003
##########
File path: src/relay/op/annotation/annotation.cc
##########
@@ -36,15 +38,40 @@
namespace tvm {
namespace relay {
-// relay.annotation.on_device
TVM_REGISTER_NODE_TYPE(OnDeviceAttrs);
+const Op& OnDeviceOp() {
+ static const Op& op = Op::Get("on_device");
+ return op;
+}
+
+Expr OnDevice(Expr expr, DLDeviceType device_type, bool is_fixed) {
+ auto attrs = make_object<OnDeviceAttrs>();
+ attrs->device_type = device_type;
+ attrs->is_fixed = is_fixed;
+ Span span = expr->span;
+ return Call(OnDeviceOp(), {std::move(expr)}, Attrs(std::move(attrs)),
/*type_args=*/{}, span);
+}
+
+Expr OptOnDevice(Expr expr, DLDeviceType device_type, bool is_fixed) {
+ if (device_type == kInvalidDeviceType) {
+ return expr;
+ }
+ if (expr->IsInstance<OpNode>() || expr->IsInstance<GlobalVarNode>() ||
+ expr->IsInstance<VarNode>() || expr->IsInstance<ConstructorNode>()) {
Review comment:
I'll avoid the clean code vs comments holy war here, it looks good now
:smile_cat:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]