Skip to content

Commit 44fb5b2

Browse files
Apply lintrunner
1 parent 6b94d87 commit 44fb5b2

File tree

15 files changed

+43
-69
lines changed

15 files changed

+43
-69
lines changed

examples/mediatek/aot_utils/oss_utils/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# LICENSE file in the root directory of this source tree.
66

77
import os
8-
from typing import Optional, Dict
8+
from typing import Dict, Optional
99

1010
import torch
1111
from executorch import exir
@@ -25,7 +25,7 @@ def build_executorch_binary(
2525
dataset,
2626
quant_dtype: Optional[Precision] = None,
2727
skip_op_name: Optional[set] = None,
28-
skip_op_type: Optional[set] = None
28+
skip_op_type: Optional[set] = None,
2929
):
3030
if quant_dtype is not None:
3131
quantizer = NeuropilotQuantizer()

examples/mediatek/model_export_scripts/dcgan.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@
88

99
if os.getcwd() not in sys.path:
1010
sys.path.append(os.getcwd())
11+
import argparse
1112
import json
1213
import os
14+
15+
import dcgan_main
1316
import numpy as np
14-
import argparse
1517

1618
import torch
17-
import dcgan_main
19+
from aot_utils.oss_utils.utils import build_executorch_binary, make_output_dir
1820
from executorch.backends.mediatek import Precision
19-
from aot_utils.oss_utils.utils import (
20-
build_executorch_binary,
21-
make_output_dir,
22-
)
2321

2422

2523
class NhwcWrappedModel(torch.nn.Module):
@@ -42,8 +40,7 @@ def forward(self, input1):
4240
parser.add_argument(
4341
"-a",
4442
"--artifact",
45-
help="path for storing generated artifacts by this example. "
46-
"Default ./dcgan",
43+
help="path for storing generated artifacts by this example. " "Default ./dcgan",
4744
default="./dcgan",
4845
type=str,
4946
)
@@ -99,4 +96,3 @@ def forward(self, input1):
9996
file_name = f"{args.artifact}/goldenD_0_0.bin"
10097
goldenD = netD_instance(inputD)
10198
goldenD.detach().numpy().tofile(file_name)
102-

examples/mediatek/model_export_scripts/dcgan_main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ def __init__(self):
2525
nn.ReLU(True),
2626
# state size. (64) x 32 x 32
2727
nn.ConvTranspose2d(64, 3, 4, 2, 1, bias=False),
28-
nn.Tanh()
28+
nn.Tanh(),
2929
# state size. (3) x 64 x 64
3030
)
3131

3232
def forward(self, input):
3333
output = self.main(input)
3434
return output
3535

36+
3637
# main_netG_input_shape = [1, 100, 1, 1]
3738
# model = Generator()
3839

@@ -58,13 +59,14 @@ def __init__(self):
5859
nn.LeakyReLU(0.2, inplace=True),
5960
# state size. (64*8) x 4 x 4
6061
nn.Conv2d(64 * 8, 1, 4, 1, 0, bias=False),
61-
nn.Sigmoid()
62+
nn.Sigmoid(),
6263
)
6364

6465
def forward(self, input):
6566
output = self.main(input)
6667

6768
return output.view(-1, 1).squeeze(1)
6869

70+
6971
# main_netD_input_shape = [1, 3, 64, 64]
7072
# model = Discriminator()

examples/mediatek/model_export_scripts/deeplab_v3.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
import numpy as np
1515

1616
import torch
17+
from aot_utils.oss_utils.utils import build_executorch_binary
1718
from executorch.backends.mediatek import Precision
18-
from aot_utils.oss_utils.utils import (
19-
build_executorch_binary,
20-
)
2119
from executorch.examples.models.deeplab_v3 import DeepLabV3ResNet101Model
2220

2321

@@ -124,7 +122,7 @@ def get_dataset(data_size, dataset_dir, download):
124122
f"{args.artifact}/{pte_filename}",
125123
inputs,
126124
quant_dtype=Precision.A8W8,
127-
skip_op_name = {
125+
skip_op_name={
128126
"aten_convolution_default_106",
129127
"aten_convolution_default_107",
130128
},

examples/mediatek/model_export_scripts/edsr.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
import numpy as np
1414

1515
import torch
16+
from aot_utils.oss_utils.utils import build_executorch_binary
1617
from executorch.backends.mediatek import Precision
17-
from aot_utils.oss_utils.utils import (
18-
build_executorch_binary,
19-
)
2018
from executorch.examples.models.edsr import EdsrModel
2119

2220
from PIL import Image

examples/mediatek/model_export_scripts/emformer_rnnt.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88

99
if os.getcwd() not in sys.path:
1010
sys.path.append(os.getcwd())
11+
import argparse
1112
import json
1213
import os
14+
1315
import numpy as np
14-
import argparse
1516

1617
import torch
18+
from aot_utils.oss_utils.utils import build_executorch_binary
19+
from executorch.backends.mediatek import Precision
1720
from executorch.examples.models.emformer_rnnt import (
18-
EmformerRnntTranscriberModel,
19-
EmformerRnntPredictorModel,
2021
EmformerRnntJoinerModel,
22+
EmformerRnntPredictorModel,
23+
EmformerRnntTranscriberModel,
2124
)
22-
from executorch.backends.mediatek import Precision
23-
from aot_utils.oss_utils.utils import build_executorch_binary
2425

2526

2627
if __name__ == "__main__":
@@ -45,10 +46,10 @@
4546
transcriber = EmformerRnntTranscriberModel()
4647
t_model = transcriber.get_eager_model()
4748
inputs = transcriber.get_example_inputs()
48-
pte_filename = 'emformer_rnnt_t_mtk'
49+
pte_filename = "emformer_rnnt_t_mtk"
4950
build_executorch_binary(
5051
t_model.eval(),
51-
inputs,
52+
inputs,
5253
f"{args.artifact}/{pte_filename}",
5354
[inputs],
5455
quant_dtype=Precision.A8W8,
@@ -79,7 +80,7 @@
7980
"aten_unsqueeze_copy_default_19",
8081
},
8182
)
82-
83+
8384
# save data to inference on device
8485
input_list_file = f"{args.artifact}/input_list_t.txt"
8586
with open(input_list_file, "w") as f:
@@ -98,7 +99,7 @@
9899
predictor = EmformerRnntPredictorModel()
99100
p_model = predictor.get_eager_model()
100101
inputs = predictor.get_example_inputs()
101-
pte_filename = 'emformer_rnnt_p_mtk'
102+
pte_filename = "emformer_rnnt_p_mtk"
102103
build_executorch_binary(
103104
p_model.eval(),
104105
inputs,
@@ -135,7 +136,7 @@
135136
joiner = EmformerRnntJoinerModel()
136137
j_model = joiner.get_eager_model()
137138
inputs = joiner.get_example_inputs()
138-
pte_filename = 'emformer_rnnt_j_mtk'
139+
pte_filename = "emformer_rnnt_j_mtk"
139140
build_executorch_binary(
140141
j_model.eval(),
141142
inputs,
@@ -159,4 +160,3 @@
159160
for idx, data in enumerate(golden):
160161
file_name = f"{args.artifact}/golden_j_0_{idx}.bin"
161162
data.detach().numpy().tofile(file_name)
162-

examples/mediatek/model_export_scripts/inception_v3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
sys.path.append(os.getcwd())
1313

1414
import torch
15+
from aot_utils.oss_utils.utils import build_executorch_binary
1516
from executorch.backends.mediatek import Precision
16-
from aot_utils.oss_utils.utils import (
17-
build_executorch_binary,
18-
)
1917
from executorch.examples.models.inception_v3 import InceptionV3Model
2018

2119

examples/mediatek/model_export_scripts/inception_v4.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
sys.path.append(os.getcwd())
1313

1414
import torch
15+
from aot_utils.oss_utils.utils import build_executorch_binary
1516
from executorch.backends.mediatek import Precision
16-
from aot_utils.oss_utils.utils import (
17-
build_executorch_binary,
18-
)
1917
from executorch.examples.models.inception_v4 import InceptionV4Model
2018

2119

examples/mediatek/model_export_scripts/mobilebert.py

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

99
if os.getcwd() not in sys.path:
1010
sys.path.append(os.getcwd())
11+
import argparse
1112
import json
1213
import os
14+
1315
import numpy as np
14-
import argparse
1516

1617
import torch
18+
from aot_utils.oss_utils.utils import build_executorch_binary, make_output_dir
1719
from executorch.backends.mediatek import Precision
1820
from executorch.examples.models.mobilebert import MobileBertModelExample
19-
from aot_utils.oss_utils.utils import (
20-
build_executorch_binary,
21-
make_output_dir,
22-
)
2321

2422

2523
if __name__ == "__main__":
@@ -55,7 +53,7 @@
5553
},
5654
)
5755

58-
#save data to inference on device
56+
# save data to inference on device
5957
golden = instance(inputs[0])
6058
input_list_file = f"{args.artifact}/input_list.txt"
6159
with open(input_list_file, "w") as f:

examples/mediatek/model_export_scripts/mobilenet_v2.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
sys.path.append(os.getcwd())
1313

1414
import torch
15+
from aot_utils.oss_utils.utils import build_executorch_binary
1516
from executorch.backends.mediatek import Precision
16-
from aot_utils.oss_utils.utils import (
17-
build_executorch_binary,
18-
)
1917
from executorch.examples.models.mobilenet_v2 import MV2Model
2018

2119

examples/mediatek/model_export_scripts/mobilenet_v3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
sys.path.append(os.getcwd())
1313

1414
import torch
15+
from aot_utils.oss_utils.utils import build_executorch_binary
1516
from executorch.backends.mediatek import Precision
16-
from aot_utils.oss_utils.utils import (
17-
build_executorch_binary,
18-
)
1917
from executorch.examples.models.mobilenet_v3 import MV3Model
2018

2119

examples/mediatek/model_export_scripts/resnet18.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
sys.path.append(os.getcwd())
1313

1414
import torch
15+
from aot_utils.oss_utils.utils import build_executorch_binary
1516
from executorch.backends.mediatek import Precision
16-
from aot_utils.oss_utils.utils import (
17-
build_executorch_binary,
18-
)
1917
from executorch.examples.models.resnet import ResNet18Model
2018

2119

examples/mediatek/model_export_scripts/resnet50.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
sys.path.append(os.getcwd())
1313

1414
import torch
15+
from aot_utils.oss_utils.utils import build_executorch_binary
1516
from executorch.backends.mediatek import Precision
16-
from aot_utils.oss_utils.utils import (
17-
build_executorch_binary,
18-
)
1917
from executorch.examples.models.resnet import ResNet50Model
2018

2119

examples/mediatek/model_export_scripts/vit_b_16.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88

99
if os.getcwd() not in sys.path:
1010
sys.path.append(os.getcwd())
11+
import argparse
1112
import json
13+
1214
import numpy as np
13-
import argparse
1415

1516
import torch
17+
from aot_utils.oss_utils.utils import build_executorch_binary, make_output_dir
1618
from executorch.backends.mediatek import Precision
1719
from executorch.examples.models.torchvision_vit import TorchVisionViTModel
18-
from aot_utils.oss_utils.utils import (
19-
build_executorch_binary,
20-
make_output_dir,
21-
)
2220

2321

2422
class NhwcWrappedModel(torch.nn.Module):
@@ -66,7 +64,7 @@ def forward(self, input1):
6664
f"{args.artifact}/{pte_filename}",
6765
[inputs],
6866
quant_dtype=Precision.A8W8,
69-
skip_op_name = {
67+
skip_op_name={
7068
"aten_permute_copy_default_4",
7169
"aten_permute_copy_default_18",
7270
"aten_permute_copy_default_32",
@@ -92,4 +90,3 @@ def forward(self, input1):
9290
file_name = f"{args.artifact}/golden_0_0.bin"
9391
golden = instance(inputs[0])
9492
golden.detach().numpy().tofile(file_name)
95-

examples/mediatek/model_export_scripts/wav2letter.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88

99
if os.getcwd() not in sys.path:
1010
sys.path.append(os.getcwd())
11+
import argparse
1112
import json
13+
1214
import numpy as np
13-
import argparse
1415

1516
import torch
17+
from aot_utils.oss_utils.utils import build_executorch_binary, make_output_dir
1618
from executorch.backends.mediatek import Precision
1719
from executorch.examples.models.wav2letter import Wav2LetterModel
18-
from aot_utils.oss_utils.utils import (
19-
build_executorch_binary,
20-
make_output_dir,
21-
)
2220

2321

2422
if __name__ == "__main__":
@@ -50,7 +48,7 @@
5048
f"{args.artifact}/{pte_filename}",
5149
[inputs],
5250
quant_dtype=Precision.A8W8,
53-
skip_op_name = {
51+
skip_op_name={
5452
"aten_convolution_default",
5553
"aten_convolution_default_1",
5654
"aten_convolution_default_9",
@@ -68,4 +66,3 @@
6866
file_name = f"{args.artifact}/golden_0_0.bin"
6967
golden = instance(inputs[0])
7068
golden.detach().numpy().tofile(file_name)
71-

0 commit comments

Comments
 (0)