Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
echarlaix committed Oct 25, 2024
1 parent 322a8af commit 9083c2b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/onnxruntime/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2192,6 +2192,18 @@ def test_compare_to_io_binding(self, model_arch):

gc.collect()

def test_default_token_type_ids(self):
model_id = MODEL_NAMES["bert"]
model = ORTModelForFeatureExtraction.from_pretrained(model_id, export=True)
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokens = tokenizer("this is a simple input", return_tensors="np")
self.assertTrue("token_type_ids" in model.input_names)
token_type_ids = tokens.pop("token_type_ids")
outs = model(token_type_ids=token_type_ids, **tokens)
outs_without_token_type_ids = model(**tokens)
self.assertTrue(np.allclose(outs.last_hidden_state, outs_without_token_type_ids.last_hidden_state))
gc.collect()


class ORTModelForMultipleChoiceIntegrationTest(ORTModelTestMixin):
# Multiple Choice tests are conducted on different models due to mismatch size in model's classifier
Expand Down

0 comments on commit 9083c2b

Please sign in to comment.