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/03/12 21:30:48 UTC

[GitHub] [tvm] u99127 commented on a change in pull request #7639: [TFLite] Cast operator adapted for MLIR-based convertor

u99127 commented on a change in pull request #7639:
URL: https://github.com/apache/tvm/pull/7639#discussion_r593461782



##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -2335,12 +2335,14 @@ def convert_cast(self, op):
         assert len(input_tensors) == 1, "input tensors length should be 1"
         input_tensor = input_tensors[0]
         in_expr = self.get_expr(input_tensor.tensor_idx)
-
-        assert op.BuiltinOptionsType() == BuiltinOptions.CastOptions
-        op_options = op.BuiltinOptions()
-        cast_options = CastOptions()
-        cast_options.Init(op_options.Bytes, op_options.Pos)
-        cast_dtype = cast_options.OutDataType()
+        if op.BuiltinOptions() is not None:
+            assert op.BuiltinOptionsType() == BuiltinOptions.CastOptions
+            op_options = op.BuiltinOptions()
+            cast_options = CastOptions()
+            cast_options.Init(op_options.Bytes, op_options.Pos)
+            cast_dtype = cast_options.OutDataType()
+        else:
+            cast_dtype = self.get_output_tensors(op)[0].tensor.Type()

Review comment:
       Is this because the cast operator can be in 2 forms, one with the type specified by BuiltinOptions.CastOptions and the other type is where there is no output data type specified by BuiltinOptions.CastOptions but we can derive the output type of the cast operator based on the type of the output tensor for the Cast operator itself ? 
   
   Is that worth stating in the commit message or in a comment ? 
   
   Ramana




----------------------------------------------------------------
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