Skip to content

Update black linter #2229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion backends/apple/mps/operators/node_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ def get_serialized_data(
def get_serialized_id(
self, node: Union[torch.fx.Node, float, int], mps_graph: MPSGraph
) -> int:

"""
Map a tensor to a unique id. If the tensor was already mapped, return
the existent id.
Expand Down
8 changes: 5 additions & 3 deletions backends/arm/arm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ def preprocess( # noqa: C901
# Add output to TOSA graph
tosa_graph.currRegion.currBasicBlock.addTensor(
output.name,
inputs[0].shape
if is_permute_node_before_addmm(node)
else output.shape,
(
inputs[0].shape
if is_permute_node_before_addmm(node)
else output.shape
),
ts.DType.INT8 if is_quant_node(node) else output.dtype,
)

Expand Down
1 change: 1 addition & 0 deletions backends/arm/arm_vela.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import numpy as np


# Pack either input or output tensor block, compose the related arrays into
# per-io structs to simplify runtime use.
def vela_bin_pack_io(prefix, data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def call(self, graph_module: torch.fx.GraphModule):
# In decomposed module, there are only input tensors for placeholder op.
for decomposed_node in decomposed_module.graph.nodes:
if decomposed_node.op == "placeholder":
decomposed_node_to_subgraph_node[
decomposed_node
] = name_to_input_tensor_map[decomposed_node.name]
decomposed_node_to_subgraph_node[decomposed_node] = (
name_to_input_tensor_map[decomposed_node.name]
)

if decomposed_node.op == "output":
last_decomposed_node = decomposed_node.args[0]
Expand Down Expand Up @@ -76,9 +76,9 @@ def call(self, graph_module: torch.fx.GraphModule):
subgraph_node.meta["source_fn_stack"] = [
(subgraph_node, subgraph_node.target)
]
decomposed_node_to_subgraph_node[
decomposed_node
] = subgraph_node
decomposed_node_to_subgraph_node[decomposed_node] = (
subgraph_node
)

graph.erase_node(node)

Expand Down
8 changes: 5 additions & 3 deletions backends/qualcomm/passes/i64_to_i32.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ def _update_meta(self, node: torch.fx.node) -> None:
meta_val = node.meta["val"]
if isinstance(meta_val, tuple):
node.meta["val"] = (
fake_tensor.to(torch.int32)
if fake_tensor.dtype == torch.int64
else fake_tensor
(
fake_tensor.to(torch.int32)
if fake_tensor.dtype == torch.int64
else fake_tensor
)
for fake_tensor in meta_val
)
else:
Expand Down
1 change: 1 addition & 0 deletions examples/arm/aot_arm_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# quantization step in our example. This will take the models
# from examples/models/ and quantize then export to delegate.


# Two simple models
class AddModule(torch.nn.Module):
def __init__(self):
Expand Down
3 changes: 2 additions & 1 deletion examples/models/llama2/quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def dynamically_quantize_per_channel(
with a final group of a size less than group size.
Assumptions:
This function assumes symmetric quantization, axis ==0 and a dense memory format."""
This function assumes symmetric quantization, axis ==0 and a dense memory format.
"""

# assumes symmetric quantization
# assumes axis == 0
Expand Down
30 changes: 15 additions & 15 deletions exir/passes/_quant_patterns_and_replacements.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ def binary_relu_op_replacement(
]


def _get_binary_ops_patterns_and_replacements() -> List[
Tuple[Callable, Callable, List[Callable]]
]:
def _get_binary_ops_patterns_and_replacements() -> (
List[Tuple[Callable, Callable, List[Callable]]]
):

# TODO: replace qbinary op with the ops implemented in lean mode
binary_op_to_qbinary_ops = {
Expand All @@ -360,9 +360,9 @@ def _get_binary_ops_patterns_and_replacements() -> List[
return pattern_and_replacements


def _get_reshape_patterns_and_replacements() -> List[
Tuple[Callable, Callable, List[Callable]]
]:
def _get_reshape_patterns_and_replacements() -> (
List[Tuple[Callable, Callable, List[Callable]]]
):
def pattern(
x,
arg0,
Expand Down Expand Up @@ -413,9 +413,9 @@ def replacement(
]


def _get_slice_patterns_and_replacements() -> List[
Tuple[Callable, Callable, List[Callable]]
]:
def _get_slice_patterns_and_replacements() -> (
List[Tuple[Callable, Callable, List[Callable]]]
):
def pattern(x, dim, start, end, x_scale, x_zero_point, x_qmin, x_qmax):
x = torch.ops.quantized_decomposed.dequantize_per_tensor.default(
x, x_scale, x_zero_point, x_qmin, x_qmax, torch.uint8
Expand All @@ -439,9 +439,9 @@ def replacement(x, dim, start, end, x_scale, x_zero_point, x_qmin, x_qmax):
]


def _get_embedding_ops_patterns_and_replacements() -> List[
Tuple[Callable, Callable, List[Callable]]
]:
def _get_embedding_ops_patterns_and_replacements() -> (
List[Tuple[Callable, Callable, List[Callable]]]
):
def get_pattern_and_replacement():
@bind_pattern_to_op(quantized_decomposed_lib, "embedding_byte")
def pattern(
Expand Down Expand Up @@ -616,9 +616,9 @@ def replacement(x, x_scale, x_zero_point, x_qmin, x_qmax):
"""


def get_quant_patterns_and_replacements() -> List[
Tuple[Callable, Callable, List[Callable]]
]:
def get_quant_patterns_and_replacements() -> (
List[Tuple[Callable, Callable, List[Callable]]]
):

return copy.copy(
[
Expand Down
6 changes: 3 additions & 3 deletions exir/serde/export_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1728,9 +1728,9 @@ def deserialize(
symbol_name_to_range,
res.names_to_symbols,
)
model_opset_version: Optional[
Dict[str, int]
] = serialized_artifact.exported_program.opset_version # pyre-ignore
model_opset_version: Optional[Dict[str, int]] = (
serialized_artifact.exported_program.opset_version # pyre-ignore
)
self._validate_model_opset_version(model_opset_version)

upgrader = GraphModuleOpUpgrader(
Expand Down
2 changes: 1 addition & 1 deletion requirements-lintrunner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pycodestyle==2.10.0
torchfix==0.1.1

# UFMT
black==22.12.0
black==24.2.0
ufmt==2.0.1
usort==1.0.5

Expand Down