Skip to content

Commit

Permalink
apply Black 2024 style in fbcode (6/16)
Browse files Browse the repository at this point in the history
Summary:
Formats the covered files with pyfmt.

paintitblack

Reviewed By: aleivag

Differential Revision: D54447740

fbshipit-source-id: e6562ba4b2cd9046d8912400ae69b2a7baa94c1e
  • Loading branch information
amyreese authored and facebook-github-bot committed Mar 3, 2024
1 parent 84a40e2 commit 6154ddd
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 42 deletions.
6 changes: 3 additions & 3 deletions mobile_cv/arch/fbnet_v2/irf_3d_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ def __init__(
in_channels=in_channels,
out_channels=mid_channels,
conv_args={
"kernel_size": pw_args.pop("kernel_size", 1)
if pw_args is not None
else 1,
"kernel_size": (
pw_args.pop("kernel_size", 1) if pw_args is not None else 1
),
"stride": pw_args.pop("stride", 1) if pw_args is not None else 1,
"padding": pw_args.pop("padding", 0) if pw_args is not None else 0,
"bias": bias,
Expand Down
48 changes: 26 additions & 22 deletions mobile_cv/arch/fbnet_v2/irf_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def __init__(
in_channels=in_channels,
out_channels=mid_channels,
conv_args={
"kernel_size": pw_args.pop("kernel_size", 1)
if pw_args is not None
else 1,
"kernel_size": (
pw_args.pop("kernel_size", 1) if pw_args is not None else 1
),
"stride": pw_args.pop("stride", 1) if pw_args is not None else 1,
"padding": pw_args.pop("padding", 0) if pw_args is not None else 0,
"bias": bias,
Expand Down Expand Up @@ -110,9 +110,11 @@ def __init__(
"bias": bias,
**hp.merge_unify_args(conv_args, dw_args),
},
bn_args=hp.merge_unify_args(bn_args, dw_bn_args)
if not dw_skip_bnrelu
else None,
bn_args=(
hp.merge_unify_args(bn_args, dw_bn_args)
if not dw_skip_bnrelu
else None
),
relu_args=relu_args if not dw_skip_bnrelu else None,
)
if not skip_dw
Expand Down Expand Up @@ -144,27 +146,29 @@ def __init__(
in_channels=mid_channels,
out_channels=out_channels,
conv_args={
"kernel_size": pwl_args.pop("kernel_size", 1)
if pwl_args is not None
else 1,
"kernel_size": (
pwl_args.pop("kernel_size", 1) if pwl_args is not None else 1
),
"stride": pwl_args.pop("stride", 1) if pwl_args is not None else 1,
"padding": pwl_args.pop("padding", 0)
if pwl_args is not None
else 0,
"padding": (
pwl_args.pop("padding", 0) if pwl_args is not None else 0
),
"bias": bias,
"groups": pwl_groups,
**hp.merge_unify_args(conv_args, pwl_args),
},
bn_args={
**hp.merge_unify_args(bn_args, pwl_bn_args),
**{
"zero_gamma": (
zero_last_bn_gamma if res_conn is not None else False
)
},
}
if not skip_pwl_bn
else None,
bn_args=(
{
**hp.merge_unify_args(bn_args, pwl_bn_args),
**{
"zero_gamma": (
zero_last_bn_gamma if res_conn is not None else False
)
},
}
if not skip_pwl_bn
else None
),
relu_args=None,
)
if not skip_pwl
Expand Down
32 changes: 18 additions & 14 deletions mobile_cv/arch/fbnet_v2/sg_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(

mid_channels = hp.get_divisible_by(
in_channels // expansion,
width_divisor
width_divisor,
# max(in_channels // expansion, out_channels // 6), 16
)

Expand Down Expand Up @@ -78,9 +78,11 @@ def __init__(
"bias": bias,
**hp.merge_unify_args(conv_args, dw_args),
},
bn_args=hp.merge_unify_args(bn_args, dw_bn_args)
if not dw_skip_bnrelu
else None,
bn_args=(
hp.merge_unify_args(bn_args, dw_bn_args)
if not dw_skip_bnrelu
else None
),
relu_args=relu_args if not dw_skip_bnrelu else None,
)

Expand Down Expand Up @@ -131,16 +133,18 @@ def __init__(
"bias": bias,
**hp.merge_unify_args(conv_args, dw_args),
},
bn_args={
**hp.merge_unify_args(bn_args, dw_bn_args),
**{
"zero_gamma": (
zero_last_bn_gamma if res_conn is not None else False
)
},
}
if not dw_skip_bnrelu
else None,
bn_args=(
{
**hp.merge_unify_args(bn_args, dw_bn_args),
**{
"zero_gamma": (
zero_last_bn_gamma if res_conn is not None else False
)
},
}
if not dw_skip_bnrelu
else None
),
relu_args=None,
)

Expand Down
6 changes: 3 additions & 3 deletions mobile_cv/arch/utils/fx_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ def create_sub_graph(
for node in sub_nodes:
node_map[node] = graph.node_copy(
node,
lambda n: node_map_input[n.name]
if n.name in node_map_input
else node_map[n],
lambda n: (
node_map_input[n.name] if n.name in node_map_input else node_map[n]
),
)

# create output
Expand Down
1 change: 1 addition & 0 deletions mobile_cv/torch/utils_caffe2/protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def get_params_from_init_net(
params: dict from blob name to numpy array
device_options: dict from blob name to the device option of its creating op
"""

# NOTE: this assumes that the params is determined by producer op with the
# only exception be CopyGPUToCPU which is CUDA op but returns CPU tensor.
def _get_device_option(producer_op):
Expand Down

0 comments on commit 6154ddd

Please sign in to comment.