Skip to content

Commit

Permalink
quanitze operation expanded to take const argument
Browse files Browse the repository at this point in the history
  • Loading branch information
d-smirnov committed Aug 27, 2020
1 parent 942c90b commit c44fee5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2763,7 +2763,12 @@ def convert_quantize(self, op):
assert len(input_tensors) == 1, "input tensors length should be 1"
input_tensor = input_tensors[0]
input_tensor_type_str = self.get_tensor_type_str(input_tensor.tensor.Type())
in_expr = self.get_expr(input_tensor.tensor_idx)

if self.has_expr(input_tensor.tensor_idx):
in_expr = self.get_expr(input_tensor.tensor_idx)
else:
in_value = self.get_tensor_value(input_tensor)
in_expr = self.exp_tab.new_const(in_value, dtype=self.get_tensor_type_str(input_tensor.tensor.Type()))

output_tensors = self.get_output_tensors(op)
assert len(output_tensors) == 1, "output tensors length should be 1"
Expand Down
2 changes: 1 addition & 1 deletion tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ def _test_quantize_dequantize(data):
# First TFLite quantize op converts float32 tensor to int8 tensor - Qnn quantize.
# Second TFLite quantize op converts int8 tensor to int8 tensor - Qnn requantize.
data_in = tf.keras.layers.Input(shape=data.shape[1:])
relu = tf.keras.layers.ReLU()(data_in)
relu = tf.keras.layers.ReLU()(data)
add = tf.keras.layers.Add()([data_in, relu])
concat = tf.keras.layers.Concatenate(axis=0)([relu, add])
keras_model = tf.keras.models.Model(inputs=data_in, outputs=concat)
Expand Down

0 comments on commit c44fee5

Please sign in to comment.