transformers
copied
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions
39 lines
1.0 KiB
39 lines
1.0 KiB
from auto_transformers import AutoTransformers
|
|
import onnx
|
|
|
|
f = open('onnx.csv', 'a+')
|
|
f.write('model_name, run op, save_onnx, check_onnx\n')
|
|
|
|
models = [
|
|
'bert-base-cased',
|
|
'distilbert-base-cased'
|
|
]
|
|
|
|
for name in models:
|
|
line = f'{name}, '
|
|
try:
|
|
op = AutoTransformers(model_name=name)
|
|
out1 = op('hello, world.')
|
|
line += 'success, '
|
|
except Exception as e:
|
|
line += 'fail, '
|
|
print(f'Fail to load op for {name}: {e}.')
|
|
continue
|
|
try:
|
|
op.save_model(format='onnx')
|
|
line += 'success, '
|
|
except Exception as e:
|
|
line += 'fail, '
|
|
print(f'Fail to save onnx for {name}: {e}.')
|
|
continue
|
|
try:
|
|
saved_name = name.replace('/', '-')
|
|
onnx_model = onnx.load(f'saved/onnx/{saved_name}.onnx')
|
|
onnx.checker.check_model(onnx_model)
|
|
line += 'success'
|
|
except Exception as e:
|
|
line += 'fail'
|
|
print(f'Fail to check onnx for {name}: {e}.')
|
|
continue
|
|
line += '\n'
|
|
f.write(line)
|