u99127 commented on a change in pull request #4788: [FRONTEND][TFLITE]Gather,
StridedSlice op support added
URL: https://github.com/apache/incubator-tvm/pull/4788#discussion_r372390838
##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -747,6 +749,158 @@ def convert_squared_difference(self, op):
out = _op.power(difference, relay.const(2, exp_type))
return out
+ def convert_gather(self, op):
+ """Method to Convert TFLite Gather operator"""
+ # Check if the input tensor is quantized, call QNN op
+ if self.is_quantized(op):
+ raise tvm.error.OpNotImplemented(
+ 'TFlite quantized gather operator is not supported yet.')
+ input_tensors = self.get_input_tensors(op)
+
+ try:
+ from tflite.BuiltinOptions import BuiltinOptions
+ from tflite.GatherOptions import GatherOptions
+ from tflite.TensorType import TensorType
+ except ImportError:
+ raise ImportError("The tflite package must be installed")
+
+ assert op.BuiltinOptionsType() == BuiltinOptions.GatherOptions
+ op_options = op.BuiltinOptions()
+ gather_options = GatherOptions()
+ gather_options.Init(op_options.Bytes, op_options.Pos)
+ axis = gather_options.Axis()
+
+ data = self.get_expr(input_tensors[0].tensor_idx)
+
+ indices = input_tensors[1]
+ indices_type = indices.tensor.Type()
+
+ assert indices_type in (TensorType.INT32, TensorType.INT64)
+ indices_type_str = self.get_tensor_type_str(indices_type)
+ indices = self.exp_tab.new_const(self.get_tensor_value(indices),
+ dtype=indices_type_str)
+ out = _op.take(data, indices, axis=axis)
+ return out
+
+ def convert_strided_slice(self, op):
+ """Method to Convert TFLite Strided Slice operator"""
+ # Check if the input tensor is quantized, call QNN op
+ if self.is_quantized(op):
+ raise tvm.error.OpNotImplemented(
+ 'TFlite quantized strided slice operator is not supported
yet.')
Review comment:
Same comment as above - this is a tensor manipulation op rather than
anything that intrinsically requires quantization knowledge.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services