tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [incubator-tvm] t-vi commented on a change in pull request #5834: Improve type handling in PyTorch frontend
Date Thu, 18 Jun 2020 08:43:30 GMT

t-vi commented on a change in pull request #5834:

File path: python/tvm/relay/frontend/
@@ -1733,12 +1780,19 @@ def _convert_dtype_value(val):
                                None:"torch.int64"} # Default is torch.int64
     if val in convert_torch_dtype_map:
-        return convert_torch_dtype_map[val]
+        return _convert_data_type(convert_torch_dtype_map[val])
         msg = "Torch data type value %d is not handled yet." % (val)
         raise NotImplementedError(msg)
-def _convert_data_type(input_type):
+def _convert_data_type(input_type, default_dtype=None):
+    """converts the PyTorch scalar type input_type to a TVM dtype.
+       optionally, default_dtype can be a TVM dtype that is used
+       if input_type is None (but not when it is unknown)"""
+    if input_type is None and default_dtype is not None:
+        return default_dtype
+    input_type = input_type.lower()
     if input_type in ["double", "torch.float64"]:
         return "float64"
     elif input_type in ["float", "torch.float32"]:

Review comment:
   float64 is not a valid input here as it will not be produced by the PyTorch JIT (which
uses double).
   One of the main points of this patch is to clearly separate PyTorch dtypes (which are input
here) from TVM dtypes (which must not be fed into this).

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

View raw message