From 524bac253f28dee356679ec02360170261ae03f1 Mon Sep 17 00:00:00 2001 From: Jared Roesch Date: Tue, 23 Oct 2018 17:08:41 -0700 Subject: [PATCH] Address feedback --- include/tvm/relay/op.h | 17 ++++++++++++++--- src/relay/pass/type_infer.cc | 4 +--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/tvm/relay/op.h b/include/tvm/relay/op.h index 7f9218599fce1..9f28fbebccfcc 100644 --- a/include/tvm/relay/op.h +++ b/include/tvm/relay/op.h @@ -485,13 +485,24 @@ inline ValueType OpMap::get(const Op& op, return map_.get(op, def_value); } +/*! + * \brief Check that an expression is a "primtive operator". + * + * Will return true if the expression is an operator which + * matches the form of primtive operators registered directly + * by the Relay codebase. + * + * That is the arguments are all type variables, and there is a single + * type relation applied to the input and output types. + */ inline bool IsPrimitiveOp(const Expr& expr) { - if (!expr.as()) { + const auto* op = expr.as(); + + if (!op) { return false; } - auto op = Downcast(expr); - auto fn_ty = op->op_type; + const auto& fn_ty = op->op_type; if (fn_ty->type_constraints.size() != 1) return false; const TypeRelationNode* rel = fn_ty->type_constraints[0].as(); diff --git a/src/relay/pass/type_infer.cc b/src/relay/pass/type_infer.cc index 351a509b28749..87fdb1c0ffbae 100644 --- a/src/relay/pass/type_infer.cc +++ b/src/relay/pass/type_infer.cc @@ -64,9 +64,7 @@ TVM_REGISTER_API("tvm.relay.type_relation.TupleGetItem") struct ResolvedTypeInfo { explicit ResolvedTypeInfo(Type checked_type, Array type_args) : checked_type(checked_type), type_args(type_args) {} - ResolvedTypeInfo(const ResolvedTypeInfo& rti) - : checked_type(rti.checked_type), type_args(rti.type_args) {} - ResolvedTypeInfo() : checked_type() {} + ResolvedTypeInfo() {} Type checked_type; // Only allocated when the expression is a call.