siju-samuel commented on a change in pull request #5330: [Frontend][TFLite]
support for FILL and SPLIT_V operators
URL: https://github.com/apache/incubator-tvm/pull/5330#discussion_r408070514
##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -1488,6 +1511,42 @@ def convert_split(self, op):
return out
+ def convert_split_v(self, op):
+ """SPLIT_V implementation."""
+ try:
+ from tflite.Operator import Operator
+ except ImportError:
+ raise ImportError("The tflite package must be installed")
+
+ assert isinstance(op, Operator)
+ input_tensors = self.get_input_tensors(op)
+
+ assert len(input_tensors) == 3, "input tensors length should be == 3"
+
+ axis_tensor = input_tensors[2]
+ split_axis = self.get_tensor_value(axis_tensor)
+ input_tensor = input_tensors[0]
+ input_tensor_idx = input_tensor.tensor_idx
+
+ in_expr = self.get_expr(input_tensor_idx)
+ if self.has_expr(input_tensors[1].tensor_idx):
+ raise tvm.error.OpNotImplemented("For size_splits parameter of
SPLIT_V operator, "
+ "only constant values are
supported.")
+
+ size_splits = list(self.get_tensor_value(input_tensors[1]))
+ size_splits = tuple(np.cumsum(size_splits)[:-1])
+
+ out = _op.split(in_expr, size_splits, axis=int(split_axis))
+ # Relay does not like a TupleWrapper of 1 element, further this
+ # only shows up with tf1.13 if we use a split with num_splits==1.
+ # In tf 1.14 this doesn't appear as it is automatically a reshape
+ # operation.
+ if isinstance(out, _expr.TupleWrapper):
+ if out.size == 1:
Review comment:
This 2 if's can be combined
----------------------------------------------------------------
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