Skip to content
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

Upgrade torch and correct dim mismatch #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion ane_transformers/huggingface/test_distilbert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (C) 2022 Apple Inc. All Rights Reserved.
#

import einops

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a 3rd party dependency that needs adding to requirements.txt + setup.py ?

from ane_transformers import testing_utils
import collections
import coremltools as ct
Expand Down Expand Up @@ -62,7 +63,12 @@ def setUpClass(cls):
cls.models[
'test'] = ane_transformers.DistilBertForSequenceClassification(
cls.models['ref'].config).eval()
cls.models['test'].load_state_dict(cls.models['ref'].state_dict())
ref_model_state = cls.models['ref'].state_dict()
ref_model_state['pre_classifier.weight'] = einops.rearrange(
ref_model_state['pre_classifier.weight'], 'd n -> d n 1 1')
ref_model_state['classifier.weight'] = einops.rearrange(
ref_model_state['classifier.weight'], 'n d -> n d 1 1')
cls.models['test'].load_state_dict(ref_model_state)
logger.info("Initialized and restored test model")

# Cache tokenized inputs and forward pass results on both the reference and test networks
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
torch>=1.10.0,<=1.11.0
torch>=2.0.0
transformers>=4.18.0
coremltools>=5.2.0
yapf
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
long_description_content_type='text/markdown',
author='Apple Inc.',
install_requires=[
"torch>=1.10.0,<=1.11.0",
"torch>=2.0.0",
"coremltools>=5.2.0",
"transformers>=4.18.0",
"protobuf>=3.1.0,<=3.20.1",
Expand Down