You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/01/07 18:02:30 UTC

[GitHub] [incubator-tvm] zhiics opened a new pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

zhiics opened a new pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643
 
 
   This PR removes the TensorObj in VM and TensorValue in interpreter. Instead, we use NDArray directly since it has been migrated to the unified object protocol, #4599 
   
   The CI may fail since there are many changes needed. Will ping reviewers when CI is green.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#issuecomment-571909750
 
 
   @wweic I am trying to only refactor tensors in the PR. The other ones may need to be either unified between VM and interpreter or changed. We will need another PR for this.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] tqchen commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
tqchen commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364363086
 
 

 ##########
 File path: python/tvm/relay/backend/interpreter.py
 ##########
 @@ -23,27 +23,13 @@
 from . import _backend
 from .. import _make, analysis, transform
 from .. import module
-from ... import register_func, nd
+from ... import nd
 from ..base import NodeBase, register_relay_node
 from ..expr import Tuple, RefCreate, Call, Constant, GlobalVar, Function, const
 from ..scope_builder import ScopeBuilder
-from . import _vm
-
-class Value(NodeBase):
-    """Base class of all values.
-    """
-    @staticmethod
-    @register_func("relay.from_scalar")
-    def from_scalar(value, dtype=None):
-        """Convert a Python scalar to a Relay scalar."""
-        return TensorValue(const(value, dtype).data)
-
-    def to_vm(self):
-        return _vm._ValueToVM(self)
-
 
 @register_relay_node
-class TupleValue(Value):
+class TupleValue(NodeBase):
 
 Review comment:
   There is no Node anymore in the c++ side, see https://github.com/apache/incubator-tvm/pull/4603 and https://github.com/apache/incubator-tvm/issues/4647
   
   So NodeBase was a legacy item that we might need to upgrade on the python side.
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#issuecomment-572724424
 
 
   @jroesch can you take another look? Should we merge?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364474121
 
 

 ##########
 File path: python/tvm/relay/backend/interpreter.py
 ##########
 @@ -23,27 +23,13 @@
 from . import _backend
 from .. import _make, analysis, transform
 from .. import module
-from ... import register_func, nd
+from ... import nd
 from ..base import NodeBase, register_relay_node
 from ..expr import Tuple, RefCreate, Call, Constant, GlobalVar, Function, const
 from ..scope_builder import ScopeBuilder
-from . import _vm
-
-class Value(NodeBase):
-    """Base class of all values.
-    """
-    @staticmethod
-    @register_func("relay.from_scalar")
-    def from_scalar(value, dtype=None):
-        """Convert a Python scalar to a Relay scalar."""
-        return TensorValue(const(value, dtype).data)
-
-    def to_vm(self):
-        return _vm._ValueToVM(self)
-
 
 @register_relay_node
-class TupleValue(Value):
+class TupleValue(NodeBase):
 
 Review comment:
   I just added a commit to replace NodeBase with Object

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364077173
 
 

 ##########
 File path: python/tvm/relay/backend/interpreter.py
 ##########
 @@ -23,27 +23,13 @@
 from . import _backend
 from .. import _make, analysis, transform
 from .. import module
-from ... import register_func, nd
+from ... import nd
 from ..base import NodeBase, register_relay_node
 from ..expr import Tuple, RefCreate, Call, Constant, GlobalVar, Function, const
 from ..scope_builder import ScopeBuilder
-from . import _vm
-
-class Value(NodeBase):
-    """Base class of all values.
-    """
-    @staticmethod
-    @register_func("relay.from_scalar")
-    def from_scalar(value, dtype=None):
-        """Convert a Python scalar to a Relay scalar."""
-        return TensorValue(const(value, dtype).data)
-
-    def to_vm(self):
-        return _vm._ValueToVM(self)
-
 
 @register_relay_node
-class TupleValue(Value):
+class TupleValue(NodeBase):
 
 Review comment:
   I noticed this as well. It is from here:
   
   https://github.com/apache/incubator-tvm/blob/bc0274d307226408c69226cf922dd916d773e265/python/tvm/_ffi/node.py#L33
   
   and used as the base by `Value` and RelayNode before so I just kept it.
   
   https://github.com/apache/incubator-tvm/blob/bc0274d307226408c69226cf922dd916d773e265/python/tvm/relay/base.py#L55
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#issuecomment-571838814
 
 
   cc @tqchen @wweic @icemelon9 @jroesch 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wweic commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
wweic commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364077225
 
 

 ##########
 File path: include/tvm/relay/interpreter.h
 ##########
 @@ -65,39 +61,21 @@ class Value;
  * \param target Compiler target flag to compile the functions on the context.
  * \return A function that takes in an expression and returns a value.
  */
-runtime::TypedPackedFunc<Value(Expr)>
+runtime::TypedPackedFunc<ObjectRef(Expr)>
 CreateInterpreter(Module mod, DLContext context, Target target);
 
-/*! \brief The base container type of Relay values. */
-class ValueNode : public RelayNode {
- public:
-  static constexpr const char* _type_key = "relay.Value";
-  TVM_DECLARE_BASE_OBJECT_INFO(ValueNode, RelayNode);
-};
-
-class Value : public ObjectRef {
- public:
-  Value() {}
-  explicit Value(ObjectPtr<Object> n) : ObjectRef(n) {}
-  const ValueNode* operator->() const {
-    return static_cast<const ValueNode*>(get());
-  }
-
-  using ContainerType = ValueNode;
-};
-
 /*! \brief A Relay closure, i.e a scope and a function. */
 class Closure;
 
 /*! \brief The container type of Closures. */
-class ClosureNode : public ValueNode {
+class ClosureNode : public Object {
 
 Review comment:
   ```suggestion
   class ClosureObj : public Object {
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wweic commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
wweic commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#issuecomment-571916869
 
 
   > @wweic I am trying to only refactor tensors in the PR. The other ones may need to be either unified between VM and interpreter or changed. We will need another PR for this.
   
   Make senses. I expect it will need more changes.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] tqchen commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#issuecomment-572852296
 
 
   still need to wait for @jroesch 's approval

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364382587
 
 

 ##########
 File path: python/tvm/relay/backend/interpreter.py
 ##########
 @@ -23,27 +23,13 @@
 from . import _backend
 from .. import _make, analysis, transform
 from .. import module
-from ... import register_func, nd
+from ... import nd
 from ..base import NodeBase, register_relay_node
 from ..expr import Tuple, RefCreate, Call, Constant, GlobalVar, Function, const
 from ..scope_builder import ScopeBuilder
-from . import _vm
-
-class Value(NodeBase):
-    """Base class of all values.
-    """
-    @staticmethod
-    @register_func("relay.from_scalar")
-    def from_scalar(value, dtype=None):
-        """Convert a Python scalar to a Relay scalar."""
-        return TensorValue(const(value, dtype).data)
-
-    def to_vm(self):
-        return _vm._ValueToVM(self)
-
 
 @register_relay_node
-class TupleValue(Value):
+class TupleValue(NodeBase):
 
 Review comment:
   Yes, I tried it, but but looks to me that we have to merge nodebase to object first before I can use object directly as there are fields not implemented in object, like getattr, etc. Should I use nodebase first then we can refactor them together?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364077173
 
 

 ##########
 File path: python/tvm/relay/backend/interpreter.py
 ##########
 @@ -23,27 +23,13 @@
 from . import _backend
 from .. import _make, analysis, transform
 from .. import module
-from ... import register_func, nd
+from ... import nd
 from ..base import NodeBase, register_relay_node
 from ..expr import Tuple, RefCreate, Call, Constant, GlobalVar, Function, const
 from ..scope_builder import ScopeBuilder
-from . import _vm
-
-class Value(NodeBase):
-    """Base class of all values.
-    """
-    @staticmethod
-    @register_func("relay.from_scalar")
-    def from_scalar(value, dtype=None):
-        """Convert a Python scalar to a Relay scalar."""
-        return TensorValue(const(value, dtype).data)
-
-    def to_vm(self):
-        return _vm._ValueToVM(self)
-
 
 @register_relay_node
-class TupleValue(Value):
+class TupleValue(NodeBase):
 
 Review comment:
   I noticed this as well. It is from here:
   
   https://github.com/apache/incubator-tvm/blob/bc0274d307226408c69226cf922dd916d773e265/python/tvm/_ffi/node.py#L33
   
   and used as the base by `Value` and RelayNode before so I just kept it.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#issuecomment-572842661
 
 
   @tqchen Done. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364077173
 
 

 ##########
 File path: python/tvm/relay/backend/interpreter.py
 ##########
 @@ -23,27 +23,13 @@
 from . import _backend
 from .. import _make, analysis, transform
 from .. import module
-from ... import register_func, nd
+from ... import nd
 from ..base import NodeBase, register_relay_node
 from ..expr import Tuple, RefCreate, Call, Constant, GlobalVar, Function, const
 from ..scope_builder import ScopeBuilder
-from . import _vm
-
-class Value(NodeBase):
-    """Base class of all values.
-    """
-    @staticmethod
-    @register_func("relay.from_scalar")
-    def from_scalar(value, dtype=None):
-        """Convert a Python scalar to a Relay scalar."""
-        return TensorValue(const(value, dtype).data)
-
-    def to_vm(self):
-        return _vm._ValueToVM(self)
-
 
 @register_relay_node
-class TupleValue(Value):
+class TupleValue(NodeBase):
 
 Review comment:
   I noticed this as well. It is from here:
   
   https://github.com/apache/incubator-tvm/blob/bc0274d307226408c69226cf922dd916d773e265/python/tvm/_ffi/node.py#L33
   
   and used as the base by `Value` before so I just kept it.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] tqchen commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#issuecomment-572805537
 
 
   @zhiics please do a rebase

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wweic commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
wweic commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364077430
 
 

 ##########
 File path: include/tvm/relay/interpreter.h
 ##########
 @@ -143,89 +121,66 @@ class RecClosureNode : public ValueNode {
   TVM_DLL static RecClosure make(Closure clos, Var bind);
 
   static constexpr const char* _type_key = "relay.RecClosure";
-  TVM_DECLARE_FINAL_OBJECT_INFO(RecClosureNode, ValueNode);
+  TVM_DECLARE_FINAL_OBJECT_INFO(RecClosureNode, Object);
 };
 
-class RecClosure : public Value {
+class RecClosure : public ObjectRef {
  public:
-  TVM_DEFINE_OBJECT_REF_METHODS(RecClosure, Value, RecClosureNode);
+  TVM_DEFINE_OBJECT_REF_METHODS(RecClosure, ObjectRef, RecClosureNode);
 };
 
 /*! \brief A tuple value. */
 class TupleValue;
 
 /*! \brief Tuple (x, ... y). */
-struct TupleValueNode : ValueNode {
-  tvm::Array<Value> fields;
+struct TupleValueNode : Object {
 
 Review comment:
   ```suggestion
   struct TupleValueObj : Object {
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364382587
 
 

 ##########
 File path: python/tvm/relay/backend/interpreter.py
 ##########
 @@ -23,27 +23,13 @@
 from . import _backend
 from .. import _make, analysis, transform
 from .. import module
-from ... import register_func, nd
+from ... import nd
 from ..base import NodeBase, register_relay_node
 from ..expr import Tuple, RefCreate, Call, Constant, GlobalVar, Function, const
 from ..scope_builder import ScopeBuilder
-from . import _vm
-
-class Value(NodeBase):
-    """Base class of all values.
-    """
-    @staticmethod
-    @register_func("relay.from_scalar")
-    def from_scalar(value, dtype=None):
-        """Convert a Python scalar to a Relay scalar."""
-        return TensorValue(const(value, dtype).data)
-
-    def to_vm(self):
-        return _vm._ValueToVM(self)
-
 
 @register_relay_node
-class TupleValue(Value):
+class TupleValue(NodeBase):
 
 Review comment:
   Yes, I tried it, but it looked to me that we have to merge nodebase to object first before I can use object directly as there are fields not implemented in object, like getattr, etc. Should I use nodebase first then we can refactor them together?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] jroesch merged pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
jroesch merged pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] jroesch commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
jroesch commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364075487
 
 

 ##########
 File path: python/tvm/relay/backend/interpreter.py
 ##########
 @@ -23,27 +23,13 @@
 from . import _backend
 from .. import _make, analysis, transform
 from .. import module
-from ... import register_func, nd
+from ... import nd
 from ..base import NodeBase, register_relay_node
 from ..expr import Tuple, RefCreate, Call, Constant, GlobalVar, Function, const
 from ..scope_builder import ScopeBuilder
-from . import _vm
-
-class Value(NodeBase):
-    """Base class of all values.
-    """
-    @staticmethod
-    @register_func("relay.from_scalar")
-    def from_scalar(value, dtype=None):
-        """Convert a Python scalar to a Relay scalar."""
-        return TensorValue(const(value, dtype).data)
-
-    def to_vm(self):
-        return _vm._ValueToVM(self)
-
 
 @register_relay_node
-class TupleValue(Value):
+class TupleValue(NodeBase):
 
 Review comment:
   Shouldn't this be Object? or the equivalent Object base class, seems wrong to inherit from node. cc @tqchen 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wweic commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
wweic commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364077343
 
 

 ##########
 File path: include/tvm/relay/interpreter.h
 ##########
 @@ -111,22 +89,22 @@ class ClosureNode : public ValueNode {
     v->Visit("func", &func);
   }
 
-  TVM_DLL static Closure make(tvm::Map<Var, Value> env, Function func);
+  TVM_DLL static Closure make(tvm::Map<Var, ObjectRef> env, Function func);
 
   static constexpr const char* _type_key = "relay.Closure";
-  TVM_DECLARE_FINAL_OBJECT_INFO(ClosureNode, ValueNode);
+  TVM_DECLARE_FINAL_OBJECT_INFO(ClosureNode, Object);
 };
 
-class Closure : public Value {
+class Closure : public ObjectRef {
  public:
-  TVM_DEFINE_OBJECT_REF_METHODS(Closure, Value, ClosureNode);
+  TVM_DEFINE_OBJECT_REF_METHODS(Closure, ObjectRef, ClosureNode);
 };
 
 /*! \brief A Relay Recursive Closure. A closure that has a name. */
 class RecClosure;
 
 /*! \brief The container type of RecClosure. */
-class RecClosureNode : public ValueNode {
+class RecClosureNode : public Object {
 
 Review comment:
   ```suggestion
   class RecClosureObj : public Object {
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] tqchen commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray

Posted by GitBox <gi...@apache.org>.
tqchen commented on a change in pull request #4643: [REFACTOR] Replace TensorObj and TensorValue with NDArray
URL: https://github.com/apache/incubator-tvm/pull/4643#discussion_r364363814
 
 

 ##########
 File path: python/tvm/relay/backend/interpreter.py
 ##########
 @@ -23,27 +23,13 @@
 from . import _backend
 from .. import _make, analysis, transform
 from .. import module
-from ... import register_func, nd
+from ... import nd
 from ..base import NodeBase, register_relay_node
 from ..expr import Tuple, RefCreate, Call, Constant, GlobalVar, Function, const
 from ..scope_builder import ScopeBuilder
-from . import _vm
-
-class Value(NodeBase):
-    """Base class of all values.
-    """
-    @staticmethod
-    @register_func("relay.from_scalar")
-    def from_scalar(value, dtype=None):
-        """Convert a Python scalar to a Relay scalar."""
-        return TensorValue(const(value, dtype).data)
-
-    def to_vm(self):
-        return _vm._ValueToVM(self)
-
 
 @register_relay_node
-class TupleValue(Value):
+class TupleValue(NodeBase):
 
 Review comment:
   Let us inherit from Object for now, and have a subsequent PR to cleanup the python side.
   
   Also seems we might be able to use Array(or ADT, see discussion here https://discuss.tvm.ai/t/discuss-runtime-array-containers-array-adt-string/4582) for this after @wweic 's PR lands 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services