Skip to content

Commit 2580dca

Browse files
committed
Address pyre checks from Meta internal tools
Signed-off-by: Per Åstrand <[email protected]> Change-Id: I60fb32ad55a3f6d3617993481ab0c1ed46cf778c
1 parent d778a98 commit 2580dca

File tree

7 files changed

+29
-13
lines changed

7 files changed

+29
-13
lines changed

backends/arm/_passes/fold_qdq_with_annotated_qparams_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def call(self, graph_module: GraphModule) -> PassResult:
9999
for i, arg in enumerate(n.args):
100100
if not isinstance(arg, Node):
101101
continue
102-
arg = cast(Node, arg)
103102

104103
# Make sure arg has requires_grad set to False
105104
# For parameters that are not quantized, sometimes (i.e. convolution)
@@ -125,7 +124,8 @@ def call(self, graph_module: GraphModule) -> PassResult:
125124
)
126125

127126
# arg.args[0] is the tensor input, replace the input usage
128-
n.replace_input_with(arg, arg.args[0])
127+
tensor_input = cast(Node, arg.args[0])
128+
n.replace_input_with(arg, tensor_input)
129129
graph_module.graph.erase_node(arg)
130130

131131
# Copy the users, since we are modifying it.

backends/arm/operators/op_avg_pool2d.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import serializer.tosa_serializer as ts
1010
import torch
11+
12+
# pyre-fixme[21]: ' Could not find a module corresponding to import `executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass`
1113
from executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass import (
1214
get_input_qparams,
1315
get_output_qparams,
@@ -80,10 +82,10 @@ def define_node(
8082

8183
accumulator_type = ts.DType.INT32
8284

83-
input_qargs = get_input_qparams(node)
85+
input_qargs = get_input_qparams(node) # pyre-ignore[16]
8486
input_zp = input_qargs[0].zp
8587

86-
output_qargs = get_output_qparams(node)
88+
output_qargs = get_output_qparams(node) # pyre-ignore[16]
8789
output_zp = output_qargs[0].zp
8890

8991
self._build_generic_avgpool2d(

backends/arm/operators/op_conv2d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def define_node(
8282
input_zp = 0
8383
if inputs[0].dtype == ts.DType.INT8:
8484
# int8 input requires quantization information
85-
input_qparams = get_input_qparams(node)
85+
input_qparams = get_input_qparams(node) # pyre-ignore[16]
8686
input_zp = input_qparams[0].zp
8787

8888
attr.ConvAttribute(
@@ -164,9 +164,9 @@ def define_node(
164164
# integer value domain of the next op. Otherwise return float32 output.
165165
if inputs[0].dtype == ts.DType.INT8:
166166
# Get scale_factor from input, weight, and output.
167-
input_scale = input_qparams[0].scale
168-
weight_scale = input_qparams[1].scale
169-
output_qargs = get_output_qparams(node)
167+
input_scale = input_qparams[0].scale # pyre-ignore [61]
168+
weight_scale = input_qparams[1].scale # pyre-ignore [61]
169+
output_qargs = get_output_qparams(node) # pyre-ignore [16]
170170
build_rescale_conv_output(
171171
tosa_graph,
172172
# pyre-fixme[61]: Uninitialized local [61]: Local variable `conv2d_res` is undefined, or not always defined.

backends/arm/operators/op_max.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import executorch.backends.arm.tosa_quant_utils as tqutils
1111
import serializer.tosa_serializer as ts
12+
13+
# pyre-fixme[21]: 'Could not find a module corresponding to import `executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass`.'
1214
from executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass import (
1315
get_input_qparams,
1416
)
@@ -43,7 +45,9 @@ def define_node(
4345
scale_back = 1.0
4446
max_output = output
4547
if inputs[0].dtype == ts.DType.INT8:
46-
input_qparams = get_input_qparams(node)
48+
input_qparams = get_input_qparams(
49+
node
50+
) # pyre-ignore[16]: 'Module `executorch.backends.arm` has no attribute `_passes`.'
4751
assert (
4852
len(input_qparams) == 2
4953
), f"Both inputs needs to have quantization information for {node}"

backends/arm/operators/op_min.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import executorch.backends.arm.tosa_quant_utils as tqutils
1111

1212
import serializer.tosa_serializer as ts
13+
14+
# pyre-fixme[21]: 'Could not find a module corresponding to import `executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass`.'
1315
from executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass import (
1416
get_input_qparams,
1517
)
@@ -44,7 +46,9 @@ def define_node(
4446
scale_back = 1.0
4547
min_output = output
4648
if inputs[0].dtype == ts.DType.INT8:
47-
input_qparams = get_input_qparams(node)
49+
input_qparams = get_input_qparams(
50+
node
51+
) # pyre-ignore[16]: 'Module `executorch.backends.arm` has no attribute `_passes`.'
4852
assert (
4953
len(input_qparams) == 2
5054
), f"Both inputs needs to have quantization information for {node}"

backends/arm/process_node.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import serializer.tosa_serializer as ts
1212
import torch
1313
import torch.fx
14+
15+
# pyre-fixme[21]: 'Could not find a module corresponding to import `executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass`.'
1416
from executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass import (
1517
get_input_qparams,
1618
)
@@ -112,7 +114,9 @@ def process_quantized_bias(
112114
_,
113115
) = consumer_node.all_input_nodes
114116

115-
input_qargs = get_input_qparams(consumer_node)
117+
input_qargs = get_input_qparams(
118+
consumer_node
119+
) # pyre-ignore[16]: Module `executorch.backends.arm` has no attribute `_passes`.
116120

117121
input_node_scale = input_qargs[0].scale
118122
weight_node_scale = input_qargs[1].scale

backends/arm/tosa_quant_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def insert_rescale_ops_to_int32(
5757
the graph upstream for DQ nodes.
5858
"""
5959

60+
# pyre-fixme[21]: 'Could not find a module corresponding to import `executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass`.'
6061
from executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass import (
6162
get_input_qparams,
6263
)
@@ -68,7 +69,7 @@ def insert_rescale_ops_to_int32(
6869
dim_order = tensor.dim_order
6970
tensor.shape = [tensor.shape[i] for i in dim_order]
7071

71-
input_qparams = get_input_qparams(node)
72+
input_qparams = get_input_qparams(node) # pyre-ignore[16]
7273
qargs = input_qparams.values()
7374

7475
# Scale the int8 quantized input to a common scale in the integer
@@ -107,11 +108,12 @@ def insert_rescale_op_to_int8(
107108
in the node meta dict as opposed to 'rescale_node_back_to_int8' which search
108109
the graph downstream for Q nodes.
109110
"""
111+
# pyre-fixme[21]: 'Could not find a module corresponding to import `executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass`.'
110112
from executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass import (
111113
get_output_qparams,
112114
)
113115

114-
output_qparams = get_output_qparams(node)
116+
output_qparams = get_output_qparams(node) # pyre-ignore[16]
115117
assert len(output_qparams) == 1, "More than one output not supported"
116118

117119
qargs_out = output_qparams[0]

0 commit comments

Comments
 (0)