Skip to content

Commit

Permalink
[QNN] Use sigmoid Lookup Table method instead of fallback to fp32 (ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyang-star authored Jul 12, 2022
1 parent 6d676ba commit ef5c3ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/tvm/relay/frontend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ def func(x):
assert len(inputs) == 3, "Input quant param not found in op inputs"
input_scale = _expr.const(inputs[1])
input_zero_point = _expr.const(inputs[2])
return qnn_torch.apply_with_fp32_fallback(data, input_scale, input_zero_point, func)
return qnn_torch.quantized_sigmoid(data, input_scale, input_zero_point)

return func(data)

Expand Down
8 changes: 8 additions & 0 deletions python/tvm/relay/frontend/qnn_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,14 @@ def quantized_relu(data, input_zero_point):
return _op.tensor.maximum(data, zp)


def quantized_sigmoid(data, input_scale, input_zero_point):
output_scale = input_scale
output_zero_point = input_zero_point
return relay.qnn.op.sigmoid(
data, input_scale, input_zero_point, output_scale, output_zero_point
)


def _quantize_per_tensor():
def _impl(inputs, _):
dim = len(infer_shape(inputs[0]))
Expand Down

0 comments on commit ef5c3ed

Please sign in to comment.