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/02/11 04:25:32 UTC
[GitHub] [incubator-tvm] tqchen opened a new pull request #4862:
[WIP][REFACTOR][PY] establish tvm.ir, migrate base, expr, type
tqchen opened a new pull request #4862: [WIP][REFACTOR][PY] establish tvm.ir, migrate base, expr, type
URL: https://github.com/apache/incubator-tvm/pull/4862
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4862: [REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
URL: https://github.com/apache/incubator-tvm/pull/4862#discussion_r377813960
##########
File path: python/tvm/ir/base.py
##########
@@ -0,0 +1,86 @@
+# 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.
+"""Span data structures."""
+import tvm._ffi
+
+from tvm.runtime import Object
+from . import _ffi_api
+
+
+class Node(Object):
+ """Base class of all IR Nodes, implements astext function."""
+ def astext(self, show_meta_data=True, annotate=None):
+ """Get the text format of the expression.
+
+ Parameters
+ ----------
+ show_meta_data : bool
+ Whether to include meta data section in the text
+ if there is meta data.
+
+ annotate: Optional[Object->str]
+ Optional annotate function to provide additional
Review comment:
Optionally
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
Posted by GitBox <gi...@apache.org>.
tqchen commented on a change in pull request #4862: [REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
URL: https://github.com/apache/incubator-tvm/pull/4862#discussion_r377831779
##########
File path: python/tvm/ir/base.py
##########
@@ -0,0 +1,86 @@
+# 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.
+"""Span data structures."""
+import tvm._ffi
+
+from tvm.runtime import Object
+from . import _ffi_api
+
+
+class Node(Object):
+ """Base class of all IR Nodes, implements astext function."""
+ def astext(self, show_meta_data=True, annotate=None):
+ """Get the text format of the expression.
+
+ Parameters
+ ----------
+ show_meta_data : bool
+ Whether to include meta data section in the text
+ if there is meta data.
+
+ annotate: Optional[Object->str]
+ Optional annotate function to provide additional
Review comment:
Optional is a type annotation in python3
----------------------------------------------------------------
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 #4862: [REFACTOR][PY]
establish tvm.ir, migrate base, expr, type, adt
Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #4862: [REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
URL: https://github.com/apache/incubator-tvm/pull/4862#issuecomment-584776027
cc @zhiics @wweic @yzhliu @icemelon9 @jroesch @MarisaKirisame @ZihengJiang
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding files
Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #4862: [REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding files
URL: https://github.com/apache/incubator-tvm/pull/4862#issuecomment-585016796
Thanks @MarisaKirisame @zhiics
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY][API-CHANGE] establish tvm.ir,
migrate corresponding relay files
Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #4862: [REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding relay files
URL: https://github.com/apache/incubator-tvm/pull/4862#issuecomment-584832133
Updated the PR and comment, @zhiics please help to take another look
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4862: [REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
URL: https://github.com/apache/incubator-tvm/pull/4862#discussion_r377817042
##########
File path: python/tvm/ir/type.py
##########
@@ -0,0 +1,205 @@
+# 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.
+"""Unified type system in the project."""
+from enum import IntEnum
+import tvm._ffi
+
+from .base import Node
+from . import _ffi_api
+
+
+class Type(Node):
+ """The base class of all types."""
+ def __eq__(self, other):
+ """Compare two types for structural equivalence."""
+ return bool(_ffi_api.type_alpha_equal(self, other))
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
+ def same_as(self, other):
+ """Compares two Relay types by referential equality."""
+ return super().__eq__(other)
+
+
+class TypeKind(IntEnum):
+ """Possible kinds of TypeVars."""
+ Type = 0
+ ShapeVar = 1
+ BaseType = 2
+ Constraint = 4
+ AdtHandle = 5
+ TypeData = 6
+
+
+@tvm._ffi.register_object("relay.TypeVar")
+class TypeVar(Type):
+ """Type parameter in functions.
+
+ A type variable represents a type placeholder which will
+ be filled in later on. This allows the user to write
+ functions which are generic over types.
+
+ Parameters
+ ----------
+ name_hint: str
+ The name of the type variable. This name only acts as a hint, and
+ is not used for equality.
+
+ kind : Optional[TypeKind]
+ The kind of the type parameter.
+ """
+ def __init__(self, name_hint, kind=TypeKind.Type):
+ self.__init_handle_by_constructor__(
+ _ffi_api.TypeVar, name_hint, kind)
+
+ def __call__(self, *args):
+ """Create a type call from this type.
+
+ Parameters
+ ----------
+ args: List[Type]
+ The arguments to the type call.
+
+ Returns
+ -------
+ call: Type
+ The result type call.
+ """
+ # pylint: disable=import-outside-toplevel
+ from .type_relation import TypeCall
+ return TypeCall(self, args)
+
+
+@tvm._ffi.register_object("relay.GlobalTypeVar")
+class GlobalTypeVar(Type):
+ """A global type variable that is used for defining new types or type aliases.
+
+ Parameters
+ ----------
+ name_hint: str
+ The name of the type variable. This name only acts as a hint, and
+ is not used for equality.
+
+ kind : Optional[TypeKind]
+ The kind of the type parameter.
+ """
+ def __init__(self, name_hint, kind=TypeKind.AdtHandle):
+ self.__init_handle_by_constructor__(
+ _ffi_api.GlobalTypeVar, name_hint, kind)
+
+ def __call__(self, *args):
+ """Create a type call from this type.
+
+ Parameters
+ ----------
+ args: List[Type]
+ The arguments to the type call.
+
+ Returns
+ -------
+ call: Type
+ The result type call.
+ """
+ # pylint: disable=import-outside-toplevel
+ from .type_relation import TypeCall
+ return TypeCall(self, args)
+
+
+@tvm._ffi.register_object("relay.TupleType")
+class TupleType(Type):
+ """The type of tuple values.
+
+ Parameters
+ ----------
+ fields : List[Type]
+ The fields in the tuple
+ """
+
+ def __init__(self, fields):
+ self.__init_handle_by_constructor__(
+ _ffi_api.TupleType, fields)
+
+
+@tvm._ffi.register_object("relay.TypeConstraint")
+class TypeConstraint(Type):
+ """Abstract class representing a type constraint."""
+
+
+@tvm._ffi.register_object("relay.FuncType")
+class FuncType(Type):
+ """Function type.
+
+
Review comment:
extra line?
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4862: [REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
URL: https://github.com/apache/incubator-tvm/pull/4862#discussion_r377813574
##########
File path: python/tvm/ir/base.py
##########
@@ -0,0 +1,86 @@
+# 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.
+"""Span data structures."""
Review comment:
The file description seems not quite accurate as there are more data structures
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY][API-CHANGE] establish tvm.ir,
migrate corresponding relay files
Posted by GitBox <gi...@apache.org>.
tqchen commented on issue #4862: [REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding relay files
URL: https://github.com/apache/incubator-tvm/pull/4862#issuecomment-584946965
The Base class has been moved to tvm.ir.RelayExpr to reflect the changes in the C++ side, so now ExprWithOp is just a temporary class to add the additional ops. RelayExpr is the real Expr class
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt, transform
Posted by GitBox <gi...@apache.org>.
tqchen commented on a change in pull request #4862: [REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt, transform
URL: https://github.com/apache/incubator-tvm/pull/4862#discussion_r377837198
##########
File path: python/tvm/ir/base.py
##########
@@ -0,0 +1,86 @@
+# 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.
+"""Span data structures."""
+import tvm._ffi
+
+from tvm.runtime import Object
+from . import _ffi_api
+
+
+class Node(Object):
+ """Base class of all IR Nodes, implements astext function."""
+ def astext(self, show_meta_data=True, annotate=None):
+ """Get the text format of the expression.
+
+ Parameters
+ ----------
+ show_meta_data : bool
+ Whether to include meta data section in the text
+ if there is meta data.
+
+ annotate: Optional[Object->str]
+ Optional annotate function to provide additional
Review comment:
ah i see, thanks for the catch!
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt, transform
Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4862: [REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt, transform
URL: https://github.com/apache/incubator-tvm/pull/4862#discussion_r377835396
##########
File path: python/tvm/ir/base.py
##########
@@ -0,0 +1,86 @@
+# 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.
+"""Span data structures."""
+import tvm._ffi
+
+from tvm.runtime import Object
+from . import _ffi_api
+
+
+class Node(Object):
+ """Base class of all IR Nodes, implements astext function."""
+ def astext(self, show_meta_data=True, annotate=None):
+ """Get the text format of the expression.
+
+ Parameters
+ ----------
+ show_meta_data : bool
+ Whether to include meta data section in the text
+ if there is meta data.
+
+ annotate: Optional[Object->str]
+ Optional annotate function to provide additional
Review comment:
yeah, I was talking about "Optional annotate function to ..." where "Optional" should be an adverb.
----------------------------------------------------------------
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 merged pull request #4862:
[REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding files
Posted by GitBox <gi...@apache.org>.
tqchen merged pull request #4862: [REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding files
URL: https://github.com/apache/incubator-tvm/pull/4862
----------------------------------------------------------------
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 edited a comment on issue #4862:
[REFACTOR][PY][API-CHANGE] establish tvm.ir,
migrate corresponding relay files
Posted by GitBox <gi...@apache.org>.
tqchen edited a comment on issue #4862: [REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding relay files
URL: https://github.com/apache/incubator-tvm/pull/4862#issuecomment-584946965
@MarisaKirisame The Base class has been moved to tvm.ir.RelayExpr to reflect the changes in the C++ side, so now ExprWithOp is just a temporary class to add the additional ops. RelayExpr is the real Expr class
----------------------------------------------------------------
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 #4862:
[REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
Posted by GitBox <gi...@apache.org>.
zhiics commented on a change in pull request #4862: [REFACTOR][PY] establish tvm.ir, migrate base, expr, type, adt
URL: https://github.com/apache/incubator-tvm/pull/4862#discussion_r377810691
##########
File path: python/tvm/ir/adt.py
##########
@@ -0,0 +1,88 @@
+# 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.
+# pylint: disable=invalid-name
+"""Algebraic data type definitions."""
+import tvm._ffi
+
+from .type import Type
+from .expr import RelayExpr
+from . import _ffi_api
+
+
+@tvm._ffi.register_object("relay.Constructor")
+class Constructor(RelayExpr):
+ """Relay ADT constructor.
+
+
Review comment:
extra line?
----------------------------------------------------------------
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