wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD &
FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971#discussion_r386006490
##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -1532,6 +1534,58 @@ def convert_pad(self, op):
out = _op.nn.pad(in_expr, pad_width=paddings, pad_value=pad_value)
return out
+ def convert_floor_div(self, op):
+ """Convert TFLite FLOOR_DIV"""
+ if self.is_quantized(op):
+ raise tvm.error.OpNotImplemented(
+ 'TFlite quantized FLOOR DIV operator is not supported yet.')
+
+ input_tensors = self.get_input_tensors(op)
+ assert len(input_tensors) == 2, "input tensors length should be 2"
+
+ lhs_tensor = input_tensors[0]
+ if self.has_expr(lhs_tensor.tensor_idx):
+ lhs_expr = self.get_expr(lhs_tensor.tensor_idx)
+ else:
+ lhs_type_str = self.get_tensor_type_str(lhs_tensor.tensor.Type())
+ lhs_expr =
self.exp_tab.new_const(self.get_tensor_value(lhs_tensor),
+ dtype=lhs_type_str)
+ rhs_tensor = input_tensors[1]
+ if self.has_expr(rhs_tensor.tensor_idx):
+ rhs_expr = self.get_expr(rhs_tensor.tensor_idx)
+ else:
+ rhs_type_str = self.get_tensor_type_str(rhs_tensor.tensor.Type())
+ rhs_expr =
self.exp_tab.new_const(self.get_tensor_value(rhs_tensor),
+ dtype=rhs_type_str)
+ out = _op.floor_divide(lhs_expr, rhs_expr)
+ return out
+
+ def convert_floor_mod(self, op):
+ """Convert TFLite FLOOR_MOD"""
+ if self.is_quantized(op):
+ raise tvm.error.OpNotImplemented(
+ 'TFlite quantized FLOOR MOD operator is not supported yet.')
+
+ input_tensors = self.get_input_tensors(op)
+ assert len(input_tensors) == 2, "input tensors length should be 2"
+
+ lhs_tensor = input_tensors[0]
+ if self.has_expr(lhs_tensor.tensor_idx):
+ lhs_expr = self.get_expr(lhs_tensor.tensor_idx)
+ else:
+ lhs_type_str = self.get_tensor_type_str(lhs_tensor.tensor.Type())
+ lhs_expr =
self.exp_tab.new_const(self.get_tensor_value(lhs_tensor),
+ dtype=lhs_type_str)
+ rhs_tensor = input_tensors[1]
+ if self.has_expr(rhs_tensor.tensor_idx):
+ rhs_expr = self.get_expr(rhs_tensor.tensor_idx)
+ else:
+ rhs_type_str = self.get_tensor_type_str(rhs_tensor.tensor.Type())
+ rhs_expr =
self.exp_tab.new_const(self.get_tensor_value(rhs_tensor),
+ dtype=rhs_type_str)
Review comment:
Same as above.
----------------------------------------------------------------
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