[REFACTOR] Get rid of packed_func_ext. (#4735)
authorTianqi Chen <tqchen@users.noreply.github.com>
Fri, 17 Jan 2020 23:11:55 +0000 (15:11 -0800)
committerGitHub <noreply@github.com>
Fri, 17 Jan 2020 23:11:55 +0000 (15:11 -0800)
Move the conversion extensions to the specific class definitions
so that we longer need to include packed_func_ext.

71 files changed:
apps/extension/src/tvm_ext.cc
include/tvm/expr.h
include/tvm/ir/expr.h
include/tvm/node/container.h
include/tvm/node/node.h
include/tvm/packed_func_ext.h [deleted file]
include/tvm/relay/transform.h
include/tvm/relay/type.h
src/api/api_arith.cc
src/api/api_base.cc
src/api/api_codegen.cc
src/api/api_ir.cc
src/api/api_lang.cc
src/api/api_pass.cc
src/api/api_schedule.cc
src/api/api_test.cc
src/arith/bound_deducer.cc
src/arith/domain_touched.cc
src/arith/int_set.cc
src/autotvm/touch_extractor.h
src/codegen/codegen_c_host.cc
src/codegen/codegen_c_host.h
src/codegen/codegen_cuda.cc
src/codegen/codegen_cuda.h
src/codegen/codegen_metal.cc
src/codegen/codegen_metal.h
src/codegen/codegen_opencl.cc
src/codegen/codegen_opencl.h
src/codegen/codegen_opengl.cc
src/codegen/codegen_opengl.h
src/codegen/codegen_vhls.h
src/codegen/datatype/registry.cc
src/codegen/intrin_rule.cc
src/codegen/intrin_rule.h
src/codegen/llvm/intrin_rule_llvm.h
src/codegen/llvm/intrin_rule_nvptx.cc
src/codegen/llvm/intrin_rule_rocm.cc
src/codegen/spirv/intrin_rule_spirv.cc
src/codegen/stackvm/codegen_stackvm.cc
src/ir/attr_functor.h
src/ir/attrs.cc
src/ir/error.cc
src/ir/expr.cc
src/ir/module.cc
src/ir/span.cc
src/ir/type.cc
src/ir/type_relation.cc
src/pass/hoist_if_then_else.cc
src/pass/inject_copy_intrin.cc
src/pass/ir_functor.cc
src/pass/lower_custom_datatypes.cc
src/pass/lower_intrin.cc
src/pass/verify_gpu_code.cc
src/relay/backend/compile_engine.cc
src/relay/backend/graph_plan_memory.cc
src/relay/backend/interpreter.cc
src/relay/backend/param_dict.h
src/relay/ir/base.cc
src/relay/ir/type.cc
src/relay/op/vision/multibox_op.cc
src/relay/pass/type_solver.cc
src/relay/qnn/util.h
src/top/operation/tensorize.cc
tests/cpp/attrs_test.cc
tests/cpp/build_module_test.cc
tests/cpp/container_test.cc
tests/cpp/packed_func_test.cc
tests/cpp/relay_build_module_test.cc
tests/cpp/relay_transform_sequential.cc
tests/cpp/utvm_runtime_standalone_test.cc
topi/src/topi.cc

index 7a685bf59e07d04cb1dad6aeab157d0f0c3f5412..b439deb755936dc9730b8a4163a6fa8f39d37486 100644 (file)
@@ -26,8 +26,8 @@
 #include <tvm/runtime/module.h>
 #include <tvm/runtime/registry.h>
 #include <tvm/runtime/ndarray.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/runtime/device_api.h>
+#include <tvm/expr_operator.h>
 
 using namespace tvm;
 using namespace tvm::runtime;
index bdd0b8f542024c1ea1178152ceece63875ab6b15..3f154da8c130f015101b96e01166ba25471b9449 100644 (file)
@@ -29,6 +29,7 @@
 #include <algorithm>
 #include <unordered_map>
 #include <iostream>
+#include <limits>
 #include "node/node.h"
 #include "node/container.h"
 #include "node/functor.h"
@@ -460,6 +461,26 @@ inline std::unordered_map<K, V> as_unordered_map(const Map<K, V>& dmap) {
 }
 }  // namespace tvm
 
+namespace tvm {
+namespace runtime {
+// Additional implementattion overloads for PackedFunc.
+inline TVMPODValue_::operator tvm::Integer() const {
+  if (type_code_ == kTVMNullptr) return Integer();
+  if (type_code_ == kDLInt) {
+    CHECK_LE(value_.v_int64, std::numeric_limits<int>::max());
+    CHECK_GE(value_.v_int64, std::numeric_limits<int>::min());
+    return Integer(static_cast<int>(value_.v_int64));
+  }
+  TVM_CHECK_TYPE_CODE(type_code_, kTVMObjectHandle);
+  Object* ptr = static_cast<Object*>(value_.v_handle);
+  CHECK(ObjectTypeChecker<Integer>::Check(ptr))
+      << "Expect type " << ObjectTypeChecker<PrimExpr>::TypeName()
+      << " but get " << ptr->GetTypeKey();
+  return Integer(ObjectPtr<Object>(ptr));
+}
+}  // namespace runtime
+}  // namespace tvm
+
 namespace std {
 template <>
 struct hash<::tvm::IterVar> : public ::tvm::ObjectHash {
index 87122e802db524f681654d4e49edfe91046a7298..e8e459744c5cd463a7b753308d131dd8bfa88a6f 100644 (file)
@@ -30,6 +30,7 @@
 #include <tvm/ir/span.h>
 #include <tvm/ir/type.h>
 #include <string>
+#include <limits>
 
 namespace tvm {
 
@@ -114,6 +115,11 @@ class PrimExpr : public BaseExpr {
   }
 
   TVM_DEFINE_OBJECT_REF_METHODS(PrimExpr, BaseExpr, PrimExprNode);
+
+ private:
+  // Internal function for conversion.
+  friend class runtime::TVMPODValue_;
+  TVM_DLL static PrimExpr FromObject_(ObjectPtr<Object> ptr);
 };
 
 /*!
@@ -321,5 +327,26 @@ inline const TTypeNode* RelayExprNode::type_as() const {
   return node;
 }
 
+}  // namespace tvm
+
+namespace tvm {
+namespace runtime {
+// Additional implementattion overloads for PackedFunc.
+inline TVMPODValue_::operator tvm::PrimExpr() const {
+  if (type_code_ == kTVMNullptr) return PrimExpr();
+  if (type_code_ == kDLInt) {
+    CHECK_LE(value_.v_int64, std::numeric_limits<int>::max());
+    CHECK_GE(value_.v_int64, std::numeric_limits<int>::min());
+    return PrimExpr(static_cast<int>(value_.v_int64));
+  }
+  if (type_code_ == kDLFloat) {
+    return PrimExpr(static_cast<float>(value_.v_float64));
+  }
+
+  TVM_CHECK_TYPE_CODE(type_code_, kTVMObjectHandle);
+  Object* ptr = static_cast<Object*>(value_.v_handle);
+  return PrimExpr::FromObject_(ObjectPtr<Object>(ptr));
+}
+}  // namespace runtime
 }  // namespace tvm
 #endif  // TVM_IR_EXPR_H_
index 7686a96c19d3ca289209a2f7e7096fe9a76d2ed8..f5c71980d9b4a125bdeaa8246abd3bb45b614d6b 100644 (file)
@@ -655,6 +655,65 @@ class Map<std::string, V, T1, T2> : public ObjectRef {
     return iterator(static_cast<const StrMapNode*>(data_.get())->data.find(key));
   }
 };
+}  // namespace tvm
 
+namespace tvm {
+namespace runtime {
+// Additional overloads for PackedFunc checking.
+template<typename T>
+struct ObjectTypeChecker<Array<T> > {
+  static bool Check(const Object* ptr) {
+    if (ptr == nullptr) return true;
+    if (!ptr->IsInstance<ArrayNode>()) return false;
+    const ArrayNode* n = static_cast<const ArrayNode*>(ptr);
+    for (const auto& p : n->data) {
+      if (!ObjectTypeChecker<T>::Check(p.get())) {
+        return false;
+      }
+    }
+    return true;
+  }
+  static std::string TypeName() {
+    return "List[" + ObjectTypeChecker<T>::TypeName() + "]";
+  }
+};
+
+template<typename V>
+struct ObjectTypeChecker<Map<std::string, V> > {
+  static bool Check(const Object* ptr) {
+    if (ptr == nullptr) return true;
+    if (!ptr->IsInstance<StrMapNode>()) return false;
+    const StrMapNode* n = static_cast<const StrMapNode*>(ptr);
+    for (const auto& kv : n->data) {
+      if (!ObjectTypeChecker<V>::Check(kv.second.get())) return false;
+    }
+    return true;
+  }
+  static std::string TypeName() {
+    return "Map[str, " +
+        ObjectTypeChecker<V>::TypeName()+ ']';
+  }
+};
+
+template<typename K, typename V>
+struct ObjectTypeChecker<Map<K, V> > {
+  static bool Check(const Object* ptr) {
+    if (ptr == nullptr) return true;
+    if (!ptr->IsInstance<MapNode>()) return false;
+    const MapNode* n = static_cast<const MapNode*>(ptr);
+    for (const auto& kv : n->data) {
+      if (!ObjectTypeChecker<K>::Check(kv.first.get())) return false;
+      if (!ObjectTypeChecker<V>::Check(kv.second.get())) return false;
+    }
+    return true;
+  }
+  static std::string TypeName() {
+    return "Map[" +
+        ObjectTypeChecker<K>::TypeName() +
+        ", " +
+        ObjectTypeChecker<V>::TypeName()+ ']';
+  }
+};
+}  // namespace runtime
 }  // namespace tvm
 #endif  // TVM_NODE_CONTAINER_H_
index 54eb436de9d3a368f8b3b99a249d11d74af0c0a0..10c577a890beae82ffece02e673edd5e92bee016 100644 (file)
@@ -56,6 +56,9 @@ using runtime::Downcast;
 using runtime::ObjectHash;
 using runtime::ObjectEqual;
 using runtime::make_object;
+using runtime::PackedFunc;
+using runtime::TVMArgs;
+using runtime::TVMRetValue;
 
 }  // namespace tvm
 #endif  // TVM_NODE_NODE_H_
diff --git a/include/tvm/packed_func_ext.h b/include/tvm/packed_func_ext.h
deleted file mode 100644 (file)
index f7b0d08..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/*!
- * \file tvm/packed_func_ext.h
- * \brief Extension package to PackedFunc
- *   This enales pass ObjectRef types into/from PackedFunc.
- */
-#ifndef TVM_PACKED_FUNC_EXT_H_
-#define TVM_PACKED_FUNC_EXT_H_
-
-#include <tvm/top/tensor.h>
-
-#include <string>
-#include <memory>
-#include <limits>
-#include <type_traits>
-
-#include "expr.h"
-#include "runtime/packed_func.h"
-
-namespace tvm {
-
-using runtime::TVMArgs;
-using runtime::TVMRetValue;
-using runtime::PackedFunc;
-
-namespace runtime {
-
-
-template<typename T>
-struct ObjectTypeChecker<Array<T> > {
-  static bool Check(const Object* ptr) {
-    if (ptr == nullptr) return true;
-    if (!ptr->IsInstance<ArrayNode>()) return false;
-    const ArrayNode* n = static_cast<const ArrayNode*>(ptr);
-    for (const auto& p : n->data) {
-      if (!ObjectTypeChecker<T>::Check(p.get())) {
-        return false;
-      }
-    }
-    return true;
-  }
-  static std::string TypeName() {
-    return "List[" + ObjectTypeChecker<T>::TypeName() + "]";
-  }
-};
-
-template<typename V>
-struct ObjectTypeChecker<Map<std::string, V> > {
-  static bool Check(const Object* ptr) {
-    if (ptr == nullptr) return true;
-    if (!ptr->IsInstance<StrMapNode>()) return false;
-    const StrMapNode* n = static_cast<const StrMapNode*>(ptr);
-    for (const auto& kv : n->data) {
-      if (!ObjectTypeChecker<V>::Check(kv.second.get())) return false;
-    }
-    return true;
-  }
-  static std::string TypeName() {
-    return "Map[str, " +
-        ObjectTypeChecker<V>::TypeName()+ ']';
-  }
-};
-
-template<typename K, typename V>
-struct ObjectTypeChecker<Map<K, V> > {
-  static bool Check(const Object* ptr) {
-    if (ptr == nullptr) return true;
-    if (!ptr->IsInstance<MapNode>()) return false;
-    const MapNode* n = static_cast<const MapNode*>(ptr);
-    for (const auto& kv : n->data) {
-      if (!ObjectTypeChecker<K>::Check(kv.first.get())) return false;
-      if (!ObjectTypeChecker<V>::Check(kv.second.get())) return false;
-    }
-    return true;
-  }
-  static std::string TypeName() {
-    return "Map[" +
-        ObjectTypeChecker<K>::TypeName() +
-        ", " +
-        ObjectTypeChecker<V>::TypeName()+ ']';
-  }
-};
-
-// extensions for tvm arg value
-inline TVMPODValue_::operator tvm::PrimExpr() const {
-  if (type_code_ == kTVMNullptr) return PrimExpr();
-  if (type_code_ == kDLInt) {
-    CHECK_LE(value_.v_int64, std::numeric_limits<int>::max());
-    CHECK_GE(value_.v_int64, std::numeric_limits<int>::min());
-    return PrimExpr(static_cast<int>(value_.v_int64));
-  }
-  if (type_code_ == kDLFloat) {
-    return PrimExpr(static_cast<float>(value_.v_float64));
-  }
-
-  TVM_CHECK_TYPE_CODE(type_code_, kTVMObjectHandle);
-  Object* ptr = static_cast<Object*>(value_.v_handle);
-
-  if (ptr->IsInstance<IterVarNode>()) {
-    return IterVar(ObjectPtr<Object>(ptr))->var;
-  }
-  if (ptr->IsInstance<top::TensorNode>()) {
-    return top::Tensor(ObjectPtr<Object>(ptr))();
-  }
-  CHECK(ObjectTypeChecker<PrimExpr>::Check(ptr))
-      << "Expect type " << ObjectTypeChecker<PrimExpr>::TypeName()
-      << " but get " << ptr->GetTypeKey();
-  return PrimExpr(ObjectPtr<Object>(ptr));
-}
-
-inline TVMPODValue_::operator tvm::Integer() const {
-  if (type_code_ == kTVMNullptr) return Integer();
-  if (type_code_ == kDLInt) {
-    CHECK_LE(value_.v_int64, std::numeric_limits<int>::max());
-    CHECK_GE(value_.v_int64, std::numeric_limits<int>::min());
-    return Integer(static_cast<int>(value_.v_int64));
-  }
-  TVM_CHECK_TYPE_CODE(type_code_, kTVMObjectHandle);
-  Object* ptr = static_cast<Object*>(value_.v_handle);
-  CHECK(ObjectTypeChecker<Integer>::Check(ptr))
-      << "Expect type " << ObjectTypeChecker<PrimExpr>::TypeName()
-      << " but get " << ptr->GetTypeKey();
-  return Integer(ObjectPtr<Object>(ptr));
-}
-}  // namespace runtime
-}  // namespace tvm
-#endif  // TVM_PACKED_FUNC_EXT_H_
index 58cfbfcc2b1d0fd93cacd944a1897493a5d9f23a..8d886aa09ea25fc371c94cbd2ab56634f0542a9e 100644 (file)
@@ -24,7 +24,6 @@
 #ifndef TVM_RELAY_TRANSFORM_H_
 #define TVM_RELAY_TRANSFORM_H_
 
-#include <tvm/packed_func_ext.h>
 #include <tvm/relay/attrs/transform.h>
 #include <tvm/ir/transform.h>
 #include <tvm/relay/expr.h>
@@ -184,7 +183,7 @@ TVM_DLL Pass InferType();
  *
  * \return The pass.
  */
-TVM_DLL Pass EliminateCommonSubexpr(PackedFunc fskip = nullptr);
+TVM_DLL Pass EliminateCommonSubexpr(runtime::PackedFunc fskip = nullptr);
 
 /*!
  * \brief Combine parallel 2d convolutions into a single convolution if the
index d4243d8526e221415b55e51d866e467401b514f2..0f81a1badc7cb3b8d1aab0a288f3ecdcb16bdb8e 100644 (file)
@@ -28,9 +28,7 @@
 #include <tvm/ir/type_relation.h>
 #include <tvm/ir/attrs.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/ir/env_func.h>
-
 #include <tvm/ir.h>
 #include <string>
 
index 0c28d08a7f28eba4438ab2615b8b789d333b9c93..0062379fd32a56396d39062e10d02c53c265c05e 100644 (file)
@@ -29,7 +29,6 @@
 #include <tvm/expr.h>
 #include <tvm/ir.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <tvm/top/tensor.h>
 
index 4b74d02cdf9e6e90967cde40dbfe0595c8840494..9078507e545394dc82faa32ad5effdd45ccdbcc0 100644 (file)
@@ -25,8 +25,6 @@
 #include <tvm/expr.h>
 #include <tvm/top/tensor.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 #include <tvm/node/serialization.h>
 
 namespace tvm {
index 1d997a2ae093b54ffb06ba2b2e89a8ab3ba1d991..6c1d193d0a3f45a1a521cb69a9d2825e893b9eca 100644 (file)
@@ -26,8 +26,6 @@
 #include <tvm/codegen.h>
 #include <tvm/lowered_func.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 
 namespace tvm {
 namespace codegen {
index 3b29ee4c85e6d048b38f18521c3d0e9ccc011685..45f7790d63d8b733b40e24c225a9e911db368ace 100644 (file)
@@ -24,7 +24,6 @@
 #include <tvm/expr.h>
 #include <tvm/ir.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <tvm/expr_operator.h>
 
index 89c2c53105073847f220ed28e04c7e014473813d..cf8e2c37d2660a96bfe63323179e5ba56ea10491 100644 (file)
@@ -28,7 +28,6 @@
 #include <tvm/buffer.h>
 #include <tvm/top/schedule.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <tvm/build_module.h>
 #include <tvm/data_layout.h>
index a822cc1402179f544e0cd97e2dd4b22889377d6a..2154ec5aa11a276b9db77f88f0da2933f8aa47f8 100644 (file)
@@ -27,8 +27,6 @@
 #include <tvm/ir_pass.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 
 namespace tvm {
 namespace ir {
index 7aa305fe0f4ae9713aed1d3c62dff170e9ac2235..976f5a4263bb2eddbe598bf5af8fa5838e0dcb02 100644 (file)
@@ -26,7 +26,6 @@
 #include <tvm/top/schedule.h>
 #include <tvm/top/schedule_pass.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include "../top/schedule/graph.h"
 
index 957a034d427f2fe3ae28e5f49cd8191916d46795..f63adb1f19ae315d87714ec5c560b0dd7cc1a5ed 100644 (file)
@@ -26,8 +26,6 @@
 #include <tvm/ir/attrs.h>
 #include <tvm/runtime/registry.h>
 #include <tvm/ir/env_func.h>
-#include <tvm/packed_func_ext.h>
-
 
 namespace tvm {
 // Attrs used to python API
index f1da23ba596f236832f356a4b813160fa97c3217..d6cd47b4ea909e7895ebda9505bbba3e7d003075 100644 (file)
@@ -26,8 +26,6 @@
 #include <tvm/ir_functor_ext.h>
 #include <tvm/arith/analyzer.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 
 #include <unordered_set>
 #include <unordered_map>
index 6e665c8bb72b53297164f2136fe00af704502166..7db03c22b748b5f894845fac7cc6d7870f771f69 100644 (file)
@@ -26,8 +26,6 @@
 #include <tvm/ir_functor_ext.h>
 #include <tvm/top/tensor.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 
 #include <unordered_set>
 #include <unordered_map>
index 82f0d2b33660b69c51aa03ccd1c499b16736b21d..2d56596860c78791ce76bf06ef612d7c35f0ad56 100644 (file)
@@ -25,7 +25,6 @@
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <utility>
 #include <algorithm>
index 3af368dca6f484373ff93c73999080076f1da0f0..360d761ba2334dcda73e6d07c4d11dbb6c3a9377 100644 (file)
@@ -28,7 +28,6 @@
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <stack>
 #include <vector>
index 083b25beddf329a2bee6cb84f7486ebcf1417629..b7cd13c916beec6e62137708d0fd9d1e040be626 100644 (file)
@@ -20,7 +20,7 @@
 /*!
  * \file codegen_c_host.cc
  */
-#include <tvm/packed_func_ext.h>
+#include <tvm/codegen.h>
 #include <vector>
 #include <string>
 #include "codegen_c_host.h"
index 43fe98d66e461ce6544e28b3bebd3cde230f1b42..94544a8c736786737bd5472c5784f79b26955fe5 100644 (file)
@@ -25,7 +25,7 @@
 #define TVM_CODEGEN_CODEGEN_C_HOST_H_
 
 #include <tvm/codegen.h>
-#include <tvm/packed_func_ext.h>
+#include <tvm/ir.h>
 #include <string>
 #include "codegen_c.h"
 
index b39965edc049d100d0741f4fcb1dfb0567129690..6f394a1e19bd35011d97ff5a16e1d725cbcbf75e 100644 (file)
@@ -22,7 +22,6 @@
  */
 
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 #include <cmath>
 #include <vector>
 #include <string>
index 23fbf7febf4e238059cc77e6cce57127e8d47825..b7b7f849974edae7b1b6662332b92be4553167e8 100644 (file)
@@ -25,7 +25,7 @@
 #define TVM_CODEGEN_CODEGEN_CUDA_H_
 
 #include <tvm/codegen.h>
-#include <tvm/packed_func_ext.h>
+#include <tvm/ir.h>
 #include <string>
 #include <unordered_map>
 #include "codegen_c.h"
index 4e92fcbbc2e51c86def3e5be5a246cd2910e941f..234e6287995333e231cdb501984344890d5f648d 100644 (file)
@@ -20,7 +20,6 @@
 /*!
  * \file codegen_metal.cc
  */
-#include <tvm/packed_func_ext.h>
 #include <vector>
 #include <string>
 #include <algorithm>
index d9c5e95c7cc37ffa950985e5db94445828cd03d1..66207897fae696c05b1aa6052c2bf288a744407c 100644 (file)
@@ -25,7 +25,6 @@
 #define TVM_CODEGEN_CODEGEN_METAL_H_
 
 #include <tvm/codegen.h>
-#include <tvm/packed_func_ext.h>
 #include <string>
 #include "codegen_c.h"
 
index ef90cfc69bd55e2dba4b33dfb6c60bcddcabb5fc..1a5107cb2160dfc02ba947ccac909a00a0fbd09b 100644 (file)
@@ -20,7 +20,6 @@
 /*!
  * \file codegen_opencl.cc
  */
-#include <tvm/packed_func_ext.h>
 #include <cmath>
 #include <vector>
 #include <string>
index 07b28fd00573d3b3e5c9621ddde76d41072f44ac..5a8bf125d4e53d18ba3080335878e60273598963 100644 (file)
@@ -25,7 +25,6 @@
 #define TVM_CODEGEN_CODEGEN_OPENCL_H_
 
 #include <tvm/codegen.h>
-#include <tvm/packed_func_ext.h>
 #include <string>
 #include "codegen_c.h"
 
index cea276d5cb1a7543334655fce36188726a90b18c..373bf38a16e8043e2591f062eb922419e85bf78e 100644 (file)
@@ -23,7 +23,6 @@
  * We are targeting OpenGL 3.3. The reason of not targeting a recent version
  * of OpenGL is to have better compatibility of WebGL 2.
  */
-#include <tvm/packed_func_ext.h>
 #include <vector>
 #include <string>
 #include <utility>
index 19ca2ee12c6c315e6d046b425b82065fe12b3a22..e7cebe01e54d85800ddf6920fe1ddfce083012ea 100644 (file)
@@ -25,7 +25,6 @@
 #define TVM_CODEGEN_CODEGEN_OPENGL_H_
 
 #include <tvm/codegen.h>
-#include <tvm/packed_func_ext.h>
 #include <string>
 #include <unordered_set>
 #include <unordered_map>
index e406cb56e40eff5c9f2e64d917e85613ab689e03..06510890980c144888c37b978177ecfacc7f51f8 100644 (file)
@@ -25,7 +25,7 @@
 #define TVM_CODEGEN_CODEGEN_VHLS_H_
 
 #include <tvm/codegen.h>
-#include <tvm/packed_func_ext.h>
+#include <tvm/ir.h>
 #include <string>
 #include "codegen_c.h"
 
index 62a75500646ada63ba147ed40aae305df8ee304d..b49b395ec08a5d8627bfc14da7062744648b1fab 100644 (file)
  * specific language governing permissions and limitations
  * under the License.
  */
-
-#include "registry.h"
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
+#include "registry.h"
 
 namespace tvm {
 namespace datatype {
 
+using runtime::TVMArgs;
+using runtime::TVMRetValue;
+
 TVM_REGISTER_GLOBAL("_datatype_register")
 .set_body([](TVMArgs args, TVMRetValue* ret) {
   datatype::Registry::Global()->Register(args[0], static_cast<uint8_t>(args[1].operator int()));
index 0609989a3362ce0992cb528653b08ba10234f7b3..699abd8db62280339d8ce1b14d59520457cf8890 100644 (file)
@@ -21,6 +21,7 @@
  * \file intrin_rule_default.cc
  * \brief Default intrinsic rules.
  */
+#include <tvm/expr_operator.h>
 #include "intrin_rule.h"
 
 namespace tvm {
index 56ba225631dfc14813b540d3ba6e185e78c4f578..b6332f1bbff35e68808e6216371a4f2960c2a24e 100644 (file)
@@ -26,9 +26,6 @@
 
 #include <tvm/ir.h>
 #include <tvm/expr.h>
-#include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 #include <tvm/runtime/registry.h>
 #include <string>
 
index 1f839f362f40a2dfdd05601df8d8d1b06e47c7a0..d81c33b701859e7cf89013f0aed67d7954f25728 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <tvm/ir.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <tvm/codegen.h>
 #include <string>
index fcd8a1a2b66479d66be05008259c50a79b920830..68475f01c39b765089feeb18e53391217dc6eec6 100644 (file)
@@ -25,8 +25,6 @@
 #include <tvm/ir.h>
 #include <tvm/expr.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 #include <sstream>
 
 namespace tvm {
index 41035af71e62da6dc9f354064d89652a3b0336fc..477bcb4f97cc7bccad3cf1302e66d0f6b0be8776 100644 (file)
@@ -25,7 +25,6 @@
 #include <tvm/ir.h>
 #include <tvm/expr.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <sstream>
 
index d96883ed02fddcd6c978f618c3e434ed32d28872..aa69ebf0ebc788ac1209bfeb13df573c75885088 100644 (file)
@@ -21,7 +21,6 @@
  * \file intrin_rule_spirv.cc
  */
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/ir.h>
 #include <GLSL.std.450.h>
 
index 8253007fff7257d341a12be5c7ef058f13d7dcfe..c12f66f37e5ebc55dadb0dda6bdd9044ac7d80c0 100644 (file)
@@ -21,7 +21,6 @@
  * \file codegen_stackvm.cc
  */
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 #include <limits>
 #include <utility>
 #include "codegen_stackvm.h"
index 68725689db134d46967fabdd8ae2d8e675c96dd4..378e8a8fd1f063c48707857aaefa0a92802a56d4 100644 (file)
@@ -31,6 +31,7 @@
 #define TVM_IR_ATTR_FUNCTOR_H_
 
 #include <tvm/node/functor.h>
+#include <tvm/ir.h>
 #include <utility>
 
 namespace tvm {
index d9063fbf0e6fab8b3bfb5805f00af4085806dbea..54f5ee2ac0c4355e205f9bfcf74fc047bf2105cc 100644 (file)
@@ -22,8 +22,6 @@
  */
 #include <tvm/ir/attrs.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 #include "attr_functor.h"
 
 namespace tvm {
index 99db14e5285df25375a9a4d547449431529af11c..62faf502e1cad959d0623fe8e8299bc41aa879e7 100644 (file)
 
 #include <tvm/ir/module.h>
 #include <tvm/ir/error.h>
-// NOTE on dependencies on relay AsText.
-// We calls into relay's printing module for better rendering.
-// These dependency does not happen at the interface-level.
-// And is only used to enhance developer experiences when relay
-// functions are presented.
+// NOTE: reverse dependency on relay.
+// These dependencies do not happen at the interface-level,
+// and are only used in minimum cases where they are clearly marked.
+//
+// Rationale: use relay's printer for astext.
 #include <tvm/relay/expr.h>
 
 #include <string>
index 0cf91c21939b0b8d3330ddca32ac359aca9eac6c..b173f4f396ba65ca481c3ee4cf64e7d66c8c3de0 100644 (file)
  */
 #include <tvm/runtime/registry.h>
 #include <tvm/ir/expr.h>
+// NOTE: reverse dependency on top/tir.
+// These dependencies do not happen at the interface-level,
+// and are only used in minimum cases where they are clearly marked.
+//
+// Rationale: convert from IterVar and top::Tensor
+#include <tvm/top/tensor.h>
+#include <tvm/expr.h>
 
 namespace tvm {
 
+PrimExpr PrimExpr::FromObject_(ObjectPtr<Object> ptr) {
+  using runtime::ObjectTypeChecker;
+  if (ptr->IsInstance<IterVarNode>()) {
+    return IterVar(ptr)->var;
+  }
+  if (ptr->IsInstance<top::TensorNode>()) {
+    return top::Tensor(ptr)();
+  }
+  CHECK(ObjectTypeChecker<PrimExpr>::Check(ptr.get()))
+      << "Expect type " << ObjectTypeChecker<PrimExpr>::TypeName()
+      << " but get " << ptr->GetTypeKey();
+  return PrimExpr(ptr);
+}
+
 IntImm::IntImm(DataType dtype, int64_t value) {
   CHECK(dtype.is_scalar())
       << "ValueError: IntImm can only take scalar.";
index 09abac712d227d68d6882b4e43d81df657d32517..01a8baaedb821aa564a90b8e07ecf4ad9ea8e517 100644 (file)
  */
 #include <tvm/runtime/registry.h>
 #include <tvm/ir/module.h>
-// NOTE on dependencies on relay analysis.
-// We calls into relay's analysis module to verify correctness
-// when a relay function is presented.
-// These dependency does not happen at the interface-level.
-// And is only used to enhance developer experiences when relay
-// functions are presented.
+// NOTE: reverse dependency on relay.
+// These dependencies do not happen at the interface-level,
+// and are only used in minimum cases where they are clearly marked.
+//
+// Rationale: We calls into relay's analysis module to verify correctness.
 #include <tvm/relay/analysis.h>
 #include <tvm/relay/transform.h>
 
index 1be4e32fb037a16c10b544ec0ce8a2a48122f372..2519321eba382270655c63ad4099380250aa7907 100644 (file)
@@ -22,7 +22,6 @@
  */
 #include <tvm/ir/span.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 namespace tvm {
 
index 4ba160758e346a1867a6d7417732407e26975fac..9e250db448755fcd62531df94b2ca9a01c0a0ae1 100644 (file)
@@ -23,8 +23,6 @@
  */
 #include <tvm/ir/type.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 namespace tvm {
 
 PrimType::PrimType(runtime::DataType dtype) {
index 06d665e8acedec6c7ebf48bd925c737e7d113948..361525c5504419c62d6931b45297d62f184106f3 100644 (file)
@@ -24,8 +24,6 @@
 #include <tvm/ir/type.h>
 #include <tvm/ir/type_relation.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 namespace tvm {
 
 TypeCall::TypeCall(Type func, tvm::Array<Type> args) {
index 78d743ac866919d2c42bf7426ad5286f0fab2a69..302abea6363fadaf952ef01dab34cae2be5e2131 100644 (file)
@@ -24,7 +24,6 @@
 #include <tvm/ir_functor_ext.h>
 #include <tvm/arith/analyzer.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <unordered_map>
 #include <unordered_set>
index af83f47d87907dadd0abe1572925dffa4993ef60..29bb5b4847747619ca265082bea24227882f317a 100644 (file)
@@ -23,7 +23,6 @@
  */
 #include <tvm/arith/pattern.h>
 #include <tvm/ir.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/ir_pass.h>
 #include "../arith/pattern_match.h"
index 2c996745fa76fe4e63cc53b14f50b792ec1ce045..7292df6cda238a88842311386e32533e4e5a186b 100644 (file)
@@ -20,7 +20,6 @@
  * \file ir_functor.cc
  */
 #include <tvm/ir_functor_ext.h>
-#include <tvm/packed_func_ext.h>
 
 namespace tvm {
 namespace ir {
index 98eaf8c58530374087c1324932246dbf0d23da90..b494328f63660d9fb41a54ee26064c54692a265b 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <tvm/ir_functor_ext.h>
 #include <tvm/ir_pass.h>
-#include <tvm/packed_func_ext.h>
 #include "../codegen/datatype/registry.h"
 
 namespace tvm {
index 7172a4a6dda2f1df32a009b3893dbc69ac46b905..4e1ea8d0b2dca192273bdbb94fa64e91afecabb5 100644 (file)
@@ -24,7 +24,6 @@
 #include <tvm/ir.h>
 #include <tvm/ir_pass.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <tvm/expr_operator.h>
 #include <unordered_set>
index 24f3e19356d490c5f849ba068143b19ad17bf5d1..f9c183eb830ea0a6b119613f41fee80830fee52d 100644 (file)
@@ -25,7 +25,6 @@
  */
 
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
index 9336782d6bc0ad31505fbba99293d19625439fa1..d32a6e2e6ff47587c386f5a4c97ef96d61af4357 100644 (file)
@@ -24,7 +24,6 @@
 #include "compile_engine.h"
 
 #include <tvm/top/schedule.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/top/operation.h>
 #include <tvm/runtime/registry.h>
 #include <tvm/relay/attrs/device_copy.h>
index de03d977f8a8be9339141c05efdd02ea5a3ee888..fd4165567e8d3031d8a369f321f128b808e50ce3 100644 (file)
@@ -22,6 +22,7 @@
  * \brief Memory index assignment pass for executing
  *   the program in the graph runtime.
  */
+#include <tvm/expr_operator.h>
 #include <tvm/relay/expr.h>
 #include <tvm/relay/expr_functor.h>
 #include <tvm/relay/analysis.h>
index ff9dbbadf30cfe8efcd00913ebb961ff48d654cc..7fdfdbb101afa41a3e9d8a0d6defd154f29657c0 100644 (file)
@@ -21,7 +21,6 @@
  * \file src/tvm/relay/interpreter.cc
  * \brief An interpreter for the Relay IR.
  */
-#include <tvm/packed_func_ext.h>
 #include <tvm/runtime/device_api.h>
 #include <tvm/relay/expr_functor.h>
 #include <tvm/relay/pattern_functor.h>
index e2d225aadd19bb3f83c2c8b833a8a0404ceffdc8..dd42eb3abfc55da3e232fabe8afea7c0a399866b 100644 (file)
@@ -25,7 +25,7 @@
 #define TVM_RELAY_BACKEND_PARAM_DICT_H_
 
 #include <tvm/node/node.h>
-#include <tvm/packed_func_ext.h>
+#include <tvm/ir.h>
 #include <tvm/runtime/ndarray.h>
 #include <tvm/runtime/packed_func.h>
 
index 82b3513979dcbe5051507fbdb6de071318f595af..85b17b5a33e0a285eccf7224473d1949f149d071 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <tvm/ir/type.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/relay/base.h>
 
 namespace tvm {
index 5680a789544c3b15add012c8a1375d07391812eb..a3b4668ad9e5d745fd7e47ec07366bbf3ce46f3f 100644 (file)
@@ -22,6 +22,7 @@
  * \brief The type system AST nodes of Relay.
  */
 #include <tvm/relay/type.h>
+#include <tvm/expr_operator.h>
 
 namespace tvm {
 namespace relay {
index 6a1b34d092d2e185e4aaa53d8c4ad50a1f2f896a..d837e99b176e3fb8a07a2fe74c57b89a1d90980e 100644 (file)
@@ -21,6 +21,7 @@
  * \file multibox_op.cc
  * \brief Multibox related operators
  */
+#include <tvm/expr_operator.h>
 #include <tvm/relay/op.h>
 #include <tvm/relay/attrs/vision.h>
 
index 30a9a5c80402a0c83eaa7d5ef0e4cb1e4d42027a..be5ac516d46af3ad3cdb1fd5c37c0dc252559b92 100644 (file)
@@ -21,6 +21,7 @@
  * \file type_solver.cc
  * \brief Type solver implementations.
  */
+#include <tvm/expr_operator.h>
 #include <string>
 #include <memory>
 #include <tuple>
index 2316bed5f5aa2ae35a49b93d0488a7c700da58c8..6c99ae13a85c4ab94f9eefc4da6ea617ab2a6881 100644 (file)
@@ -26,6 +26,7 @@
 #define TVM_RELAY_QNN_UTIL_H_
 
 #include <tvm/expr.h>
+#include <tvm/expr_operator.h>
 #include <tvm/relay/expr.h>
 #include <tvm/relay/qnn/attrs.h>
 #include <limits>
index 413bb424b72052e366af6d4906b78c16e9a55ca2..e7f6b33608cb38cc0bc83bce911e4013e6efd21c 100644 (file)
@@ -25,7 +25,6 @@
 #include <tvm/ir_functor_ext.h>
 #include <tvm/ir_pass.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 
 #include "op_util.h"
 #include "compute_op.h"
index 730d2042ae96951d152ae39e2d1b59dd14a657a6..b87576e750946dae9430f99f883cbf9ff2d2c58e 100644 (file)
@@ -21,7 +21,6 @@
 #include <gtest/gtest.h>
 #include <tvm/ir/attrs.h>
 #include <tvm/expr_operator.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/ir.h>
 
 namespace tvm {
index 30834c5af46ce9ff947902fc1b1e0448e80645b5..31d82f0e47115c0923452ea89766a723cea7cb7c 100644 (file)
@@ -22,7 +22,6 @@
 #include <topi/cuda/injective.h>
 #include <tvm/top/operation.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/build_module.h>
 
 #include <string>
index d5d8aae9f687d89e059ac40235c9a75dd21a8b56..5988b2ad2b0ac4237ab223d050a26a583c0aa9fb 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <dmlc/logging.h>
 #include <gtest/gtest.h>
-#include <tvm/packed_func_ext.h>
+#include <tvm/expr_operator.h>
 #include <tvm/runtime/container.h>
 #include <new>
 #include <unordered_map>
index f4f960144be1203d90a5f9525fc31fd3576f041f..550c93eea3a55f3a8b6b60f0171826246bde925e 100644 (file)
@@ -21,8 +21,6 @@
 #include <gtest/gtest.h>
 #include <tvm/runtime/packed_func.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-#include <tvm/runtime/registry.h>
 #include <tvm/ir.h>
 
 TEST(PackedFunc, Basic) {
index 462d0fe12eba9875c6aa3ef765a316fd1caa4d4f..bf0e338a7c7adc21d4f5a8a66dd084ebe400fc3e 100644 (file)
@@ -28,8 +28,6 @@
 #include <tvm/runtime/packed_func.h>
 #include <tvm/runtime/module.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
-
 
 TVM_REGISTER_GLOBAL("test.sch")
 .set_body([](tvm::TVMArgs args, tvm::TVMRetValue *rv) {
index 4c383b5af4e1283eb5824591f5f03e4fc8d51f60..4171f9dedc2f5c3a58f101eb5084faf0b944f0a9 100644 (file)
@@ -20,7 +20,6 @@
 #include <gtest/gtest.h>
 #include <topi/generic/injective.h>
 #include <tvm/build_module.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/relay/expr.h>
 #include <tvm/ir/module.h>
 #include <tvm/relay/analysis.h>
index 73a624584749586055b9bcc2cd25fe48a259e323..bde3245220b637f2155d519c36965a8855bbb040 100644 (file)
@@ -33,7 +33,6 @@
 #include <topi/generic/injective.h>
 #include <tvm/build_module.h>
 #include <tvm/top/operation.h>
-#include <tvm/packed_func_ext.h>
 #include <tvm/relay/analysis.h>
 #include <tvm/relay/expr.h>
 #include <tvm/relay/transform.h>
index 8197e891d15472a04f45c882aeeffe3bcc66cb01..7ae4d88d110f36f20a73d5f686e5acaafa4950c0 100644 (file)
@@ -26,7 +26,7 @@
 #include <tvm/runtime/packed_func.h>
 #include <tvm/runtime/module.h>
 #include <tvm/runtime/registry.h>
-#include <tvm/packed_func_ext.h>
+#include <tvm/ir/expr.h>
 #include <tvm/build_module.h>
 
 #include <topi/broadcast.h>