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

Fixed the segmentation fault in CamemBERT and VIT #6

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

Yiran-ASU
Copy link
Collaborator

No description provided.

@@ -24,6 +24,7 @@ def __init__(self, model_name: str):
self.layer3 = AutoModelForTokenClassification.from_pretrained(model_name).classifier

def forward(self, input):
x = input.reshape(1, 7, 768)
Copy link
Owner

Choose a reason for hiding this comment

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

Hmmm, I don't see how this works. Shouldn't it be input = instead of x =? And you already did example_input = example_input.reshape(1, 7*768) in line 50 but reshape it back here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, my mistake

@@ -44,7 +45,10 @@ def forward(self, input):

print("Parsing sentence tokens.")
example_input = prepare_sentence_tokens(model_name, sentence)
print(example_input.shape)
print("example_input shape: ", example_input.shape)
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add comment above this line to show what is the original shape?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure

@@ -47,6 +47,7 @@ def forward(self, input):
example_input = prepare_sentence_tokens(model_name, sentence)
print("example_input shape: ", example_input.shape)

# The original example_input shape is [1, 7, 768], now we reshape it into [1, 7*768]
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add an assert here to make sure the shape is [1, 7, 768]?

@@ -47,6 +47,7 @@ def forward(self, input):
example_input = prepare_sentence_tokens(model_name, sentence)
print("example_input shape: ", example_input.shape)

# The original example_input shape is [1, 7, 768], now we reshape it into [1, 7*768]
example_input = example_input.reshape(1, 7*768)
Copy link
Owner

Choose a reason for hiding this comment

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

Plz try reshape(7*768)?

@tancheng tancheng merged commit 0ea2b53 into tancheng:main Oct 9, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants