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 2021/08/19 06:39:15 UTC

[GitHub] [tvm] hhhfccz opened a new pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

hhhfccz opened a new pull request #8790:
URL: https://github.com/apache/tvm/pull/8790


   Initial OneFlow frontend support, also add tutorials and tests.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1015777678


   The new image with oneflow installed will go online once https://github.com/apache/tvm/pull/9965 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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1021917960


   > Shall we try landing this PR?
   
   I agree!


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1054640225


   I think CI is not running any oneflow tests. You need to update https://github.com/apache/tvm/blob/main/tests/scripts/task_python_frontend.sh
   
   > It is not depend on libibverbs
   
   Can you do more investigation on this. It may depend on it indirectly via other deps. Remember that we are using the oneflow CPU build.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011449613


   @BBuf so the image `tlcpackstaging/ci_gpu:20220112-000102-d1ee20191` https://hub.docker.com/layers/tlcpackstaging/ci_gpu/20220112-000102-d1ee20191/images/sha256-6c9bd4cef78df644fa1cee7dd8b2915488572543e2407f29044e38861616b350?context=explore has oneflow installed, but when I test the installation locally I got this error:
   ```
   >>> import oneflow                                                                                                                                                           
   libibverbs not available, ibv_fork_init skipped                                                                                                                              
   W0112 20:58:52.579394    22 cuda_device_descriptor_class.cpp:48] CUDA driver version is insufficient for CUDA runtime version
   >>> oneflow.__version__
   '0.6.0+cu110'
   ```
   Can you test this locally if this is a real problem? The cuda version on CI is
   ```
   # nvcc --version
   nvcc: NVIDIA (R) Cuda compiler driver
   Copyright (c) 2005-2020 NVIDIA Corporation
   Built on Wed_Jul_22_19:09:09_PDT_2020
   Cuda compilation tools, release 11.0, V11.0.221
   Build cuda_11.0_bu.TC445_37.28845127_0
   ```


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r782230355



##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {

Review comment:
       yes, good idea.




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r782943840



##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []
+
+
+def is_input_op(node):
+    # Determine if the the node is the input of graph
+    return node.WhichOneof("op_type") == "input_conf"
+
+
+def is_user_op(node):
+    # Determine if the the node is the intermediate variables of graph
+    return node.WhichOneof("op_type") == "user_conf"
+
+
+def is_output_op(node):
+    # Determine if the the node is the output of graph
+    return node.WhichOneof("op_type") == "output_conf"
+
+
+def is_param_op(node):
+    # Determine if the the node is the intermediate variables of model(saved)
+    return node.WhichOneof("op_type") == "variable_conf"
+
+
+def get_node_info(node):
+    """
+    Get basic information about nodes: shape、data_type
+    """
+    # list->tuple
+    shape = tuple(node.input_conf.blob_conf.shape.dim)
+    # get data type
+    dtype = node.input_conf.blob_conf.data_type
+    if dtype in list(FLOW_2_NP_DTYPE.keys()):
+        data_type = FLOW_2_NP_DTYPE[dtype]
+    else:
+        raise IndexError('Please check the data type of your node: %s' % node.name)
+
+    return shape, data_type
+
+
+def parse_attr(attr):
+    # Parse node_attr
+    attrs = {}
+    for a in attr:
+        attr_str = str(attr[a])
+
+        if attr_str[0:7] == "at_list":
+            attr_str_ = attr_str.split(" ")[0]
+
+            if attr_str_ == "at_list_float":
+                attrs[a] = tuple(attr[a].at_list_float.val)
+            elif attr_str_ == "at_list_int32":
+                attrs[a] = tuple(attr[a].at_list_int32.val)
+            elif attr_str_ == "at_list_int64":
+                attrs[a] = tuple(attr[a].at_list_int64.val)
+
+        elif attr_str.split(":")[0] == "at_string":
+            attrs[a] = attr[a].at_string
+
+        elif attr_str.split(" ")[0] == "at_shape":
+            attrs[a] = tuple(list(attr[a].at_shape.dim))
+
+        else:
+            attr_str_ = attr_str.split(":")[0]
+            if attr_str_ == "at_bool":
+                attrs[a] = attr[a].at_bool
+            elif attr_str_ == "at_double":
+                attrs[a] = attr[a].at_double
+            elif attr_str_ == "at_float":
+                attrs[a] = attr[a].at_float
+            elif attr_str_ == "at_int32":
+                attrs[a] = attr[a].at_int32
+            elif attr_str_ == "at_int64":
+                attrs[a] = attr[a].at_int64
+
+    return attrs
+
+
+def shape_of(x, dtype="int64"):
+    ttype = infer_type(x).checked_type
+    if not _ty.is_dynamic(ttype):
+        shape = list(ttype.shape)
+        return _expr.const(shape, dtype)
+
+    return _op.shape_of(x, dtype)
+
+
+def dimension_constraint():
+    def _dim_check(attrs):
+        if len(attrs["kernel_size"]) in [1, 2, 3]:
+            return True
+        return False
+
+    return _dim_check, "Only 1d, 2d and 3d kernel supported."
+
+
+class OneFlowOpConverter(object):
+    """A helper class for holding oneflow op converters."""
+
+    @classmethod
+    def get_converter(cls):
+        """
+        Get converter matches given opset.
+        Parameters
+        ----------
+        None
+
+        Returns
+        -------
+        converter, which should be `_impl_vx`.
+        """
+        version = 1
+        if hasattr(cls, "_impl_v{}".format(version)):
+            return getattr(cls, "_impl_v{}".format(version))
+        raise NotImplementedError(
+            "version {} of {} not implemented".format(version, cls.__name__)
+        )
+
+
+class Pool(OneFlowOpConverter):
+    """A helper class for pool op converters."""
+    name = ""

Review comment:
       We originally thought that oneflow has a dynamic graph and a static graph mode, so we wanted to distinguish it by the version number. However, this logic does not seem to be very necessary at present, but I have no idea how to change it now. This can be refactored after I think about it later. So, can this PR ignore this for now? 




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011449613


   @BBuf so the image `tlcpackstaging/ci_gpu:20211219-100400-c0d326dbd` has oneflow installed, but when I test the installation locally I got this error:
   ```
   >>> import oneflow                                                                                                                                                           
   libibverbs not available, ibv_fork_init skipped                                                                                                                              
   W0112 20:58:52.579394    22 cuda_device_descriptor_class.cpp:48] CUDA driver version is insufficient for CUDA runtime version
   >>> oneflow.__version__
   '0.6.0+cu110'
   ```
   Can you test this locally if this is a real problem? The cuda version on CI is
   ```
   # nvcc --version
   nvcc: NVIDIA (R) Cuda compiler driver
   Copyright (c) 2005-2020 NVIDIA Corporation
   Built on Wed_Jul_22_19:09:09_PDT_2020
   Cuda compilation tools, release 11.0, V11.0.221
   Build cuda_11.0_bu.TC445_37.28845127_0
   ```


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r782239869



##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []

Review comment:
       ok.




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1017276942


   > 
   
   Ok, thanks! In a few days , I will open a public project in OneFlow-Inc to store the codes of OneFlow models (classification, detection, segmentation, transformer...) to TVM. 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf removed a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf removed a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1053857761


   When compiling the docstring, CI shows that it can not import the skimage package. How can I solve it? @masahi   The link is: https://ci.tlcpack.ai/blue/organizations/jenkins/tvm/detail/PR-8790/11/pipeline


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1054189941


   > Have you reproduced that issue locally using docker?
   > 
   > Does oneflow depend on `libibverbs`?
   
   It is not depend on `libibverbs` 。


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011600468


   > 
   
   Ok, thanks.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011625760


   I think it's whatever version that comes with this nvidia container https://github.com/apache/tvm/blob/main/docker/Dockerfile.ci_gpu#L20. I'm not familiar with this issue.
   
   Now that I think about it, I don't think there is a need to install a gpu-enabled version of oneflow, since we only need it for testing / model ingestion purpose. If there is no matching build, we can always fallback to the cpu build and we'll update the image.  
   
   


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-901658497


   Hello, TVM developers. We have recently done a work to add a new deep learning framework OneFlow to the TVM front-end, hope this work can be received.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1017276942


   > 
   
   Okay thank you! In a few days , I will open a public project in OneFlow-Inc to store the codes of OneFlow models (classification, detection, segmentation, transformer...) to TVM. 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r787098337



##########
File path: tests/python/frontend/oneflow/test_forward.py
##########
@@ -359,7 +359,7 @@ def forward(self, x):
     model = Conv2dModel()
     model.eval()
 
-    for device in ["llvm", "cuda"]:

Review comment:
       I didn't see the update? Still only llvm is being tested.




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1054874077


   > 
   
   
   
   > I think CI is not running any oneflow tests. You need to update https://github.com/apache/tvm/blob/main/tests/scripts/task_python_frontend.sh
   > 
   > > It is not depend on libibverbs
   > 
   > Can you do more investigation on this. It may depend on it indirectly via other deps. Remember that we are using the oneflow CPU build.
   
   Ok, thanks.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1017276942


   > 
   
   Ok, thanks! In a few days , I will open a public project in OneFlow-Inc to store the codes of OneFlow models (classification, detection, segmentation, transformer...) to TVM. 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r783590577



##########
File path: tests/python/frontend/oneflow/test_forward.py
##########
@@ -359,7 +359,7 @@ def forward(self, x):
     model = Conv2dModel()
     model.eval()
 
-    for device in ["llvm", "cuda"]:

Review comment:
       You can (and should) test cuda on TVM, just need to compare against the CPU reference from oneflow.




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r783593376



##########
File path: tests/python/frontend/oneflow/test_forward.py
##########
@@ -359,7 +359,7 @@ def forward(self, x):
     model = Conv2dModel()
     model.eval()
 
-    for device in ["llvm", "cuda"]:

Review comment:
       OK, I just updated,and [this pr](https://github.com/apache/tvm/pull/9922) changed oneflow to cpu installation.




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1053857761


   When compiling the docstring, CI shows that it can not import the skimage package. How can I solve it? @masahi   The link is: https://ci.tlcpack.ai/blue/organizations/jenkins/tvm/detail/PR-8790/11/pipeline


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1054000729


   Have you reproduced that issue locally using docker?
   
   Does oneflow depend on `libibverbs`? 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011631461


   > I think it's whatever version that comes with this nvidia container https://github.com/apache/tvm/blob/main/docker/Dockerfile.ci_gpu#L20. I'm not familiar with this issue.
   > 
   > Now that I think about it, I don't think there is a need to install a gpu-enabled version of oneflow, since we only need it for testing / model ingestion purpose. If there is no matching build, we can always fallback to the cpu build and we'll update the image.
   
   Ok, do I need to submit a PR to install the cpu version of OneFlow? 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r782643076



##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []
+
+
+def is_input_op(node):
+    # Determine if the the node is the input of graph
+    return node.WhichOneof("op_type") == "input_conf"
+
+
+def is_user_op(node):
+    # Determine if the the node is the intermediate variables of graph
+    return node.WhichOneof("op_type") == "user_conf"
+
+
+def is_output_op(node):
+    # Determine if the the node is the output of graph
+    return node.WhichOneof("op_type") == "output_conf"
+
+
+def is_param_op(node):
+    # Determine if the the node is the intermediate variables of model(saved)
+    return node.WhichOneof("op_type") == "variable_conf"
+
+
+def get_node_info(node):
+    """
+    Get basic information about nodes: shape、data_type
+    """
+    # list->tuple
+    shape = tuple(node.input_conf.blob_conf.shape.dim)
+    # get data type
+    dtype = node.input_conf.blob_conf.data_type
+    if dtype in list(FLOW_2_NP_DTYPE.keys()):
+        data_type = FLOW_2_NP_DTYPE[dtype]
+    else:
+        raise IndexError('Please check the data type of your node: %s' % node.name)
+
+    return shape, data_type
+
+
+def parse_attr(attr):
+    # Parse node_attr
+    attrs = {}
+    for a in attr:
+        attr_str = str(attr[a])
+
+        if attr_str[0:7] == "at_list":
+            attr_str_ = attr_str.split(" ")[0]
+
+            if attr_str_ == "at_list_float":
+                attrs[a] = tuple(attr[a].at_list_float.val)
+            elif attr_str_ == "at_list_int32":
+                attrs[a] = tuple(attr[a].at_list_int32.val)
+            elif attr_str_ == "at_list_int64":
+                attrs[a] = tuple(attr[a].at_list_int64.val)
+
+        elif attr_str.split(":")[0] == "at_string":
+            attrs[a] = attr[a].at_string
+
+        elif attr_str.split(" ")[0] == "at_shape":
+            attrs[a] = tuple(list(attr[a].at_shape.dim))
+
+        else:
+            attr_str_ = attr_str.split(":")[0]
+            if attr_str_ == "at_bool":
+                attrs[a] = attr[a].at_bool
+            elif attr_str_ == "at_double":
+                attrs[a] = attr[a].at_double
+            elif attr_str_ == "at_float":
+                attrs[a] = attr[a].at_float
+            elif attr_str_ == "at_int32":
+                attrs[a] = attr[a].at_int32
+            elif attr_str_ == "at_int64":
+                attrs[a] = attr[a].at_int64
+
+    return attrs
+
+
+def shape_of(x, dtype="int64"):
+    ttype = infer_type(x).checked_type
+    if not _ty.is_dynamic(ttype):
+        shape = list(ttype.shape)
+        return _expr.const(shape, dtype)
+
+    return _op.shape_of(x, dtype)
+
+
+def dimension_constraint():
+    def _dim_check(attrs):
+        if len(attrs["kernel_size"]) in [1, 2, 3]:
+            return True
+        return False
+
+    return _dim_check, "Only 1d, 2d and 3d kernel supported."
+
+
+class OneFlowOpConverter(object):
+    """A helper class for holding oneflow op converters."""
+
+    @classmethod
+    def get_converter(cls):
+        """
+        Get converter matches given opset.
+        Parameters
+        ----------
+        None
+
+        Returns
+        -------
+        converter, which should be `_impl_vx`.
+        """
+        version = 1
+        if hasattr(cls, "_impl_v{}".format(version)):
+            return getattr(cls, "_impl_v{}".format(version))
+        raise NotImplementedError(
+            "version {} of {} not implemented".format(version, cls.__name__)
+        )
+
+
+class Pool(OneFlowOpConverter):
+    """A helper class for pool op converters."""
+    name = ""

Review comment:
       I think also it is unnecessary, I will solve 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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011639230


   But you still need to update `Dockerfile.ci_gpu` (as in in your previous PR), not `Dockerfile.ci_cpu`. We don't run frontend tests on `ci_cpu`. Just replace one line in your previous PR.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1048423634


   > You need to pass ci.
   
   ok,I will deal with 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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1048422817


   You need to pass ci.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1054000729


   Have you reproduced that issue locally using docker?


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-901658497


   Hello, TVM developers. We have recently done a work to add a new deep learning framework OneFlow to the TVM front-end, hope this work can be received.
   
   @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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] jcf94 edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
jcf94 edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-907055939


   Thanks! @hhhfccz We've just merged the frontend support for PaddlePaddle in #8645, you can check about what that PR did to speed up the review of this PR.
   
   Several basic things:
   1. Clean the CI linting;
   2. Add clear doc to functions;
   3. Have enough UTs and make them work in the CI(maybe you also need to add OneFlow to the CI docker?)


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] jcf94 commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
jcf94 commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-907055939


   Thanks! @hhhfccz We've just merged the frontend support for PaddlePaddle in #8645, you can check about what that PR did.
   Several basic things:
   1. Clean the ci linting;
   2. Add clear doc to functions;
   3. Have enough UTs and make them work in the CI(maybe you also need to add OneFlow to the CI docker?)


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-901712215


   Yeah we find it super exciting and happy to discuss more with the RFC process


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r782225978



##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []
+
+
+def is_input_op(node):
+    # Determine if the the node is the input of graph
+    return node.WhichOneof("op_type") == "input_conf"
+
+
+def is_user_op(node):
+    # Determine if the the node is the intermediate variables of graph
+    return node.WhichOneof("op_type") == "user_conf"
+
+
+def is_output_op(node):
+    # Determine if the the node is the output of graph
+    return node.WhichOneof("op_type") == "output_conf"
+
+
+def is_param_op(node):
+    # Determine if the the node is the intermediate variables of model(saved)
+    return node.WhichOneof("op_type") == "variable_conf"
+
+
+def get_node_info(node):
+    """
+    Get basic information about nodes: shape、data_type
+    """
+    # list->tuple
+    shape = tuple(node.input_conf.blob_conf.shape.dim)
+    # get data type
+    dtype = node.input_conf.blob_conf.data_type
+    if dtype in list(FLOW_2_NP_DTYPE.keys()):
+        data_type = FLOW_2_NP_DTYPE[dtype]
+    else:
+        raise IndexError('Please check the data type of your node: %s' % node.name)
+
+    return shape, data_type
+
+
+def parse_attr(attr):
+    # Parse node_attr

Review comment:
       ok。




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011449613


   @BBuf so the image `tlcpackstaging/ci_gpu:20211219-100400-c0d326dbd` https://hub.docker.com/layers/tlcpackstaging/ci_gpu/20220112-000102-d1ee20191/images/sha256-6c9bd4cef78df644fa1cee7dd8b2915488572543e2407f29044e38861616b350?context=explore has oneflow installed, but when I test the installation locally I got this error:
   ```
   >>> import oneflow                                                                                                                                                           
   libibverbs not available, ibv_fork_init skipped                                                                                                                              
   W0112 20:58:52.579394    22 cuda_device_descriptor_class.cpp:48] CUDA driver version is insufficient for CUDA runtime version
   >>> oneflow.__version__
   '0.6.0+cu110'
   ```
   Can you test this locally if this is a real problem? The cuda version on CI is
   ```
   # nvcc --version
   nvcc: NVIDIA (R) Cuda compiler driver
   Copyright (c) 2005-2020 NVIDIA Corporation
   Built on Wed_Jul_22_19:09:09_PDT_2020
   Cuda compilation tools, release 11.0, V11.0.221
   Build cuda_11.0_bu.TC445_37.28845127_0
   ```


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1021916547


   Shall we try landing this PR?


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1054391343


   The tests related to the oneflow front-end in ci have all passed (indicating that oneflow can be imported normally), but it only hangs when the html corresponding to the document is compiled, and no specific reason is given. But I can run this `from_oneflow.py` normally in local. If it is convenient, can you help to confirm the source of this error? I compared the format of `from_oneflow.py` and `from_onnx.py` line by line, and found no problem.  Thanks! @masahi 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1054391343


   The tests related to the oneflow front-end in ci have all passed (indicating that oneflow can be imported normally), but it only hangs when the html corresponding to the document is compiled, and no specific reason is given. But I can run this `from_oneflow.py` normally, if it is convenient, can you help to confirm the source of this error? I compared the format of `from_oneflow.py` and `from_onnx.py` line by line, and found no problem.  Thanks! @masahi 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] jcf94 edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
jcf94 edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-907055939


   Thanks! @hhhfccz We've just merged the frontend support for PaddlePaddle in #8645, you can check about what that PR did to speed up the review of this PR.
   
   Several basic things:
   1. Clean the ci linting;
   2. Add clear doc to functions;
   3. Have enough UTs and make them work in the CI(maybe you also need to add OneFlow to the CI docker?)


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1054391343


   The tests related to the oneflow front-end in ci have all passed (indicating that oneflow can be imported normally), but it only hangs when the html corresponding to the document is compiled, and no specific reason is given. But I can run this `from_oneflow.py` normally, if it is convenient, can you help to confirm the source of this error? I compared the format of `from_oneflow.py` and `from_onnx.py` line by line, and found no problem.  Thanks!


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1053991772


   Hello, this pr will make an error in the document compilation part, it seems that oneflow cannot be imported correctly in docker. What do I need to do? https://ci.tlcpack.ai/blue/organizations/jenkins/tvm/detail/PR-8790/12/pipeline/318 @masahi 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf edited a comment on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf edited a comment on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-901658497


   Hello, TVM developers. We have recently done a work to add a new deep learning framework [OneFlow](https://github.com/Oneflow-Inc/oneflow) to the TVM front-end, hope this work can be received.
   
   @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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1008442952


   @hhhfccz please update this PR, and prepare CI for oneflow if not done yet.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011613582


   > @BBuf so the image `tlcpackstaging/ci_gpu:20211219-100400-c0d326dbd` https://hub.docker.com/layers/tlcpackstaging/ci_gpu/20220112-000102-d1ee20191/images/sha256-6c9bd4cef78df644fa1cee7dd8b2915488572543e2407f29044e38861616b350?context=explore has oneflow installed, but when I test the installation locally I got this error:
   > 
   > ```
   > >>> import oneflow                                                                                                                                                           
   > libibverbs not available, ibv_fork_init skipped                                                                                                                              
   > W0112 20:58:52.579394    22 cuda_device_descriptor_class.cpp:48] CUDA driver version is insufficient for CUDA runtime version
   > >>> oneflow.__version__
   > '0.6.0+cu110'
   > ```
   > 
   > Can you test this locally if this is a real problem? The cuda version on CI is
   > 
   > ```
   > # nvcc --version
   > nvcc: NVIDIA (R) Cuda compiler driver
   > Copyright (c) 2005-2020 NVIDIA Corporation
   > Built on Wed_Jul_22_19:09:09_PDT_2020
   > Cuda compilation tools, release 11.0, V11.0.221
   > Build cuda_11.0_bu.TC445_37.28845127_0
   > ```
   
   ![图片](https://user-images.githubusercontent.com/35585791/149246904-a2ebf195-1569-4e9a-b419-de7bd679de53.png)
   
   As you can see from here, installing the CUDA10 version of OneFlow requires the system's CUDA Driver Version>=450.36.06. The CUDA Driver Version of my machine is 460.91.03, which can install and use OneFlow normally. So, what is the CUDA Driver Version of docker image `tlcpackstaging/ci_gpu:20211219-100400-c0d326dbd` ?


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011639081


   > Yes that would be the easiest, unless you have a good reason to use a gpu-enabled build.
   
   Ok, i'll do it later. 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1017271439


   The image is already updated and should be ready for oneflow. I can merge your PR, but since I'm not familiar with oneflow, I won't actually take a deep look at the code and instead trust your expertise on 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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r782643076



##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []
+
+
+def is_input_op(node):
+    # Determine if the the node is the input of graph
+    return node.WhichOneof("op_type") == "input_conf"
+
+
+def is_user_op(node):
+    # Determine if the the node is the intermediate variables of graph
+    return node.WhichOneof("op_type") == "user_conf"
+
+
+def is_output_op(node):
+    # Determine if the the node is the output of graph
+    return node.WhichOneof("op_type") == "output_conf"
+
+
+def is_param_op(node):
+    # Determine if the the node is the intermediate variables of model(saved)
+    return node.WhichOneof("op_type") == "variable_conf"
+
+
+def get_node_info(node):
+    """
+    Get basic information about nodes: shape、data_type
+    """
+    # list->tuple
+    shape = tuple(node.input_conf.blob_conf.shape.dim)
+    # get data type
+    dtype = node.input_conf.blob_conf.data_type
+    if dtype in list(FLOW_2_NP_DTYPE.keys()):
+        data_type = FLOW_2_NP_DTYPE[dtype]
+    else:
+        raise IndexError('Please check the data type of your node: %s' % node.name)
+
+    return shape, data_type
+
+
+def parse_attr(attr):
+    # Parse node_attr
+    attrs = {}
+    for a in attr:
+        attr_str = str(attr[a])
+
+        if attr_str[0:7] == "at_list":
+            attr_str_ = attr_str.split(" ")[0]
+
+            if attr_str_ == "at_list_float":
+                attrs[a] = tuple(attr[a].at_list_float.val)
+            elif attr_str_ == "at_list_int32":
+                attrs[a] = tuple(attr[a].at_list_int32.val)
+            elif attr_str_ == "at_list_int64":
+                attrs[a] = tuple(attr[a].at_list_int64.val)
+
+        elif attr_str.split(":")[0] == "at_string":
+            attrs[a] = attr[a].at_string
+
+        elif attr_str.split(" ")[0] == "at_shape":
+            attrs[a] = tuple(list(attr[a].at_shape.dim))
+
+        else:
+            attr_str_ = attr_str.split(":")[0]
+            if attr_str_ == "at_bool":
+                attrs[a] = attr[a].at_bool
+            elif attr_str_ == "at_double":
+                attrs[a] = attr[a].at_double
+            elif attr_str_ == "at_float":
+                attrs[a] = attr[a].at_float
+            elif attr_str_ == "at_int32":
+                attrs[a] = attr[a].at_int32
+            elif attr_str_ == "at_int64":
+                attrs[a] = attr[a].at_int64
+
+    return attrs
+
+
+def shape_of(x, dtype="int64"):
+    ttype = infer_type(x).checked_type
+    if not _ty.is_dynamic(ttype):
+        shape = list(ttype.shape)
+        return _expr.const(shape, dtype)
+
+    return _op.shape_of(x, dtype)
+
+
+def dimension_constraint():
+    def _dim_check(attrs):
+        if len(attrs["kernel_size"]) in [1, 2, 3]:
+            return True
+        return False
+
+    return _dim_check, "Only 1d, 2d and 3d kernel supported."
+
+
+class OneFlowOpConverter(object):
+    """A helper class for holding oneflow op converters."""
+
+    @classmethod
+    def get_converter(cls):
+        """
+        Get converter matches given opset.
+        Parameters
+        ----------
+        None
+
+        Returns
+        -------
+        converter, which should be `_impl_vx`.
+        """
+        version = 1
+        if hasattr(cls, "_impl_v{}".format(version)):
+            return getattr(cls, "_impl_v{}".format(version))
+        raise NotImplementedError(
+            "version {} of {} not implemented".format(version, cls.__name__)
+        )
+
+
+class Pool(OneFlowOpConverter):
+    """A helper class for pool op converters."""
+    name = ""

Review comment:
       I think also it is unnecessary, I will solve 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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011639230


   But you still need to update `Dockerfile.ci_gpu` (as in in your previous PR), not `Dockerfile.ci_cpu`. We don't run frontend tests on `ci_cpu`.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011416144


   I'm testing a new GPU image that includes oneflow at https://github.com/apache/tvm/commits/ci-docker-staging. Once the CI passes, I'll send a PR to update our `main` CI to it. After that, you should be able to run oneflow tests on our CI.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1048419148


   > Shall we try landing this PR?
   
   Hello, can this pr be approve and merge now?


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1017262846


   > The new image with oneflow installed will go online once #9965 lands
   
   Thanks. In addition, I would like to know who can review this pr again? thank you in advance. 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r782936686



##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []
+
+
+def is_input_op(node):
+    # Determine if the the node is the input of graph

Review comment:
       ok,I have solved 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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1010909738


   @masahi @areusch   I have dealt with the comments, please help to review again, thank you very much. 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] BBuf commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
BBuf commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011640049


   > But you still need to update `Dockerfile.ci_gpu` (as in in your previous PR), not `Dockerfile.ci_cpu`. We don't run frontend tests on `ci_cpu`.
   
   Ok,thanks.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
masahi commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-1011637875


   Yes that would be the easiest, unless you have a good reason to use a gpu-enabled build. 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] junrushao1994 commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
junrushao1994 commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-907058135


   OneFlow installation in the CI’s docker image is required in a separate PR. After the docker image PR is merged, you guys may use https://github.com/apache/tvm/issues/8824 as a template for bumping CI versions. The PaddlePaddle frontend PR is a good example of how things works :-)


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#discussion_r699089815



##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []
+
+
+def is_input_op(node):
+    # Determine if the the node is the input of graph
+    return node.WhichOneof("op_type") == "input_conf"
+
+
+def is_user_op(node):
+    # Determine if the the node is the intermediate variables of graph
+    return node.WhichOneof("op_type") == "user_conf"
+
+
+def is_output_op(node):
+    # Determine if the the node is the output of graph
+    return node.WhichOneof("op_type") == "output_conf"
+
+
+def is_param_op(node):
+    # Determine if the the node is the intermediate variables of model(saved)
+    return node.WhichOneof("op_type") == "variable_conf"
+
+
+def get_node_info(node):
+    """
+    Get basic information about nodes: shape、data_type
+    """
+    # list->tuple
+    shape = tuple(node.input_conf.blob_conf.shape.dim)
+    # get data type
+    dtype = node.input_conf.blob_conf.data_type
+    if dtype in list(FLOW_2_NP_DTYPE.keys()):
+        data_type = FLOW_2_NP_DTYPE[dtype]
+    else:
+        raise IndexError('Please check the data type of your node: %s' % node.name)
+
+    return shape, data_type
+
+
+def parse_attr(attr):
+    # Parse node_attr

Review comment:
       can you make this docstring and add a bit more detail considering the complexity of the function?

##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []
+
+
+def is_input_op(node):
+    # Determine if the the node is the input of graph

Review comment:
       can you put these one-liners as docstrings? and also explicitly document the polarity of these functions. e.g.
   
   ```
   def is_input_op(node):
       """Return true when the node is the input of the graph."""
   ```

##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []
+
+
+def is_input_op(node):
+    # Determine if the the node is the input of graph
+    return node.WhichOneof("op_type") == "input_conf"
+
+
+def is_user_op(node):
+    # Determine if the the node is the intermediate variables of graph
+    return node.WhichOneof("op_type") == "user_conf"
+
+
+def is_output_op(node):
+    # Determine if the the node is the output of graph
+    return node.WhichOneof("op_type") == "output_conf"
+
+
+def is_param_op(node):
+    # Determine if the the node is the intermediate variables of model(saved)
+    return node.WhichOneof("op_type") == "variable_conf"
+
+
+def get_node_info(node):
+    """
+    Get basic information about nodes: shape、data_type
+    """
+    # list->tuple
+    shape = tuple(node.input_conf.blob_conf.shape.dim)
+    # get data type
+    dtype = node.input_conf.blob_conf.data_type
+    if dtype in list(FLOW_2_NP_DTYPE.keys()):
+        data_type = FLOW_2_NP_DTYPE[dtype]
+    else:
+        raise IndexError('Please check the data type of your node: %s' % node.name)
+
+    return shape, data_type
+
+
+def parse_attr(attr):
+    # Parse node_attr
+    attrs = {}
+    for a in attr:
+        attr_str = str(attr[a])
+
+        if attr_str[0:7] == "at_list":
+            attr_str_ = attr_str.split(" ")[0]
+
+            if attr_str_ == "at_list_float":
+                attrs[a] = tuple(attr[a].at_list_float.val)
+            elif attr_str_ == "at_list_int32":
+                attrs[a] = tuple(attr[a].at_list_int32.val)
+            elif attr_str_ == "at_list_int64":
+                attrs[a] = tuple(attr[a].at_list_int64.val)
+
+        elif attr_str.split(":")[0] == "at_string":
+            attrs[a] = attr[a].at_string
+
+        elif attr_str.split(" ")[0] == "at_shape":
+            attrs[a] = tuple(list(attr[a].at_shape.dim))
+
+        else:
+            attr_str_ = attr_str.split(":")[0]
+            if attr_str_ == "at_bool":
+                attrs[a] = attr[a].at_bool
+            elif attr_str_ == "at_double":
+                attrs[a] = attr[a].at_double
+            elif attr_str_ == "at_float":
+                attrs[a] = attr[a].at_float
+            elif attr_str_ == "at_int32":
+                attrs[a] = attr[a].at_int32
+            elif attr_str_ == "at_int64":
+                attrs[a] = attr[a].at_int64
+
+    return attrs
+
+
+def shape_of(x, dtype="int64"):
+    ttype = infer_type(x).checked_type
+    if not _ty.is_dynamic(ttype):
+        shape = list(ttype.shape)
+        return _expr.const(shape, dtype)
+
+    return _op.shape_of(x, dtype)
+
+
+def dimension_constraint():
+    def _dim_check(attrs):
+        if len(attrs["kernel_size"]) in [1, 2, 3]:
+            return True
+        return False
+
+    return _dim_check, "Only 1d, 2d and 3d kernel supported."
+
+
+class OneFlowOpConverter(object):
+    """A helper class for holding oneflow op converters."""
+
+    @classmethod
+    def get_converter(cls):
+        """
+        Get converter matches given opset.
+        Parameters
+        ----------
+        None
+
+        Returns
+        -------
+        converter, which should be `_impl_vx`.
+        """
+        version = 1
+        if hasattr(cls, "_impl_v{}".format(version)):
+            return getattr(cls, "_impl_v{}".format(version))
+        raise NotImplementedError(
+            "version {} of {} not implemented".format(version, cls.__name__)
+        )
+
+
+class Pool(OneFlowOpConverter):
+    """A helper class for pool op converters."""
+    name = ""

Review comment:
       what's the point of the class-level variable?

##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {

Review comment:
       possible to construct this from FLOW_2_STR_DTYPE? e.g. 
   ```
   FLOW_2_NP_DTYPE = {k: getattr(np, v) for k, v in FLOW_2_STR_DTYPE.items()}
   ```

##########
File path: python/tvm/relay/frontend/oneflow.py
##########
@@ -0,0 +1,1842 @@
+# 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, import-self, len-as-condition, unused-argument, too-many-lines
+# pylint: disable=import-outside-toplevel
+"""OF: OneFlow frontend"""
+import os
+import re
+import copy
+import warnings
+
+import numpy as np
+import tvm
+from tvm.ir import IRModule
+from tvm.topi.utils import get_const_tuple
+
+from .. import analysis
+from .. import expr as _expr
+from .. import function as _function
+from .. import op as _op
+from .. import ty as _ty
+from .common import (
+    AttrCvt,
+    Renamer,
+    fold_constant,
+    get_name,
+    get_relay_op,
+    infer_channels,
+    infer_shape,
+    infer_type,
+    infer_value,
+    new_var,
+)
+
+__all__ = ["from_oneflow"]
+
+FLOW_2_STR_DTYPE = {
+    2: "float32",
+    3: "float64",
+    6: "int64",
+    5: "int32",
+    4: "int8",
+    7: "uint8",
+    9: "float16"
+}
+
+FLOW_2_NP_DTYPE = {
+    2: np.float32,
+    3: np.float64,
+    6: np.int64,
+    5: np.int32,
+    4: np.int8,
+    7: np.uint8,
+    9: np.float16
+}
+
+_identity_list = []

Review comment:
       is it possible to avoid the list as a global? it's easy to leave things in here and forget to remove them, and then poison a second function call to this module.




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] comaniac commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
comaniac commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-901702219


   Thanks for the PR. For large scope new features, we recommend to file an RFC first to propose the motivation, approach and interfaces to the community for discussions. Please see the guideline here: https://github.com/apache/tvm-rfcs


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] hhhfccz commented on pull request #8790: [RELAY][FRONTEND] Initial OneFlow frontend support.

Posted by GitBox <gi...@apache.org>.
hhhfccz commented on pull request #8790:
URL: https://github.com/apache/tvm/pull/8790#issuecomment-901654622


   @areusch @comaniac @Huyuwei 


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org