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 2019/12/12 06:15:06 UTC

[GitHub] [incubator-tvm] FrozenGene commented on a change in pull request #4502: [Relay][Frontend][TFlite] Add parses support for SLICE

FrozenGene commented on a change in pull request #4502: [Relay][Frontend][TFlite] Add parses support for SLICE
URL: https://github.com/apache/incubator-tvm/pull/4502#discussion_r356973198
 
 

 ##########
 File path: python/tvm/relay/frontend/tflite.py
 ##########
 @@ -1033,6 +1034,35 @@ def convert_split(self, op):
 
         return out
 
+    def convert_slice(self, op):
+        """Convert TFLite SLICE"""
+        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"
+        input_tensor = input_tensors[0]
+        in_expr = self.get_expr(input_tensor.tensor_idx)
+
+        begin = list(self.get_tensor_value(input_tensors[1]))
+        size = list(self.get_tensor_value(input_tensors[2]))
+        # strided_slice(Relay) needs the slice's end indices, not the size
+        end = size
+        input_tensor_shape = input_tensor.tensor.ShapeAsNumpy()
+        input_tensor_rank = len(input_tensor_shape)
+        for i in range(input_tensor_rank):
+            if size[i] == -1:
+                end[i] = input_tensor_shape[i] - begin[i] + 1
 
 Review comment:
   The `+1` is correct? see tf frontend: https://github.com/apache/incubator-tvm/blob/master/python/tvm/relay/frontend/tensorflow.py#L627 Let us make sure again. If tf is wrong, please fix tf frontend.

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


With regards,
Apache Git Services