transformers
copied
Jael Gu
3 years ago
2 changed files with 22 additions and 1 deletions
@ -0,0 +1,18 @@ |
|||||
|
from auto_transformers import AutoTransformers |
||||
|
|
||||
|
import torch |
||||
|
|
||||
|
models = ['bert-base-cased', 'distilbert-base-cased', 'distilgpt2'] |
||||
|
|
||||
|
for name in models: |
||||
|
try: |
||||
|
op = AutoTransformers(model_name=name) |
||||
|
out1 = op('hello, world.') |
||||
|
op.save_model() |
||||
|
op.model = torch.jit.load(name + '.pt') |
||||
|
out2 = op('hello, world.') |
||||
|
assert (out1 == out2).all() |
||||
|
print(f'[SUCCESS] Saved torchscript for model "{name}"') |
||||
|
except Exception as e: |
||||
|
print(f'[ERROR] Fail for model "{name}": {e}.') |
||||
|
continue |
Loading…
Reference in new issue