-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix rotary embedding oob issue #29014
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
74b7b14
105f0f7
2a92d95
bf5813d
89def7b
71a3352
e95943c
327e2dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1412,5 +1412,34 @@ TEST(RotaryEmbeddingTest, RotaryEmbedding_PositionIds_OOB_InBatch_WebGPU_Passthr | |
| test.Run(OpTester::ExpectResult::kExpectSuccess, "", {}, nullptr, &execution_providers); | ||
| } | ||
|
|
||
| // Test that cos_cache dimension exceeding hidden_size is rejected when rotary_embedding_dim=0. | ||
| TEST(RotaryEmbeddingTest, RotaryEmbedding_RejectsCosCacheExceedsHiddenSize) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: the name |
||
| // hidden_size = 64, cos_cache dim1 = 64 => effective rotary dim = 128 > 64 | ||
| int batch_size = 1; | ||
| int sequence_length = 1; | ||
| int hidden_size = 64; | ||
| int half_rotary_dim = 64; // makes cos_cache_dims[1]*2 = 128 > hidden_size | ||
| int max_sequence_length = 2; | ||
|
|
||
| OpTester test("RotaryEmbedding", 23, onnxruntime::kOnnxDomain); | ||
| test.AddAttribute<int64_t>("interleaved", static_cast<int64_t>(0)); | ||
| test.AddAttribute<int64_t>("num_heads", static_cast<int64_t>(1)); | ||
|
|
||
| test.AddInput<float>("input", {batch_size, sequence_length, hidden_size}, | ||
| std::vector<float>(hidden_size, 42.0f)); | ||
| test.AddInput<float>("cos_cache", {max_sequence_length, half_rotary_dim}, | ||
| std::vector<float>(max_sequence_length * half_rotary_dim, 0.0f)); | ||
| test.AddInput<float>("sin_cache", {max_sequence_length, half_rotary_dim}, | ||
| std::vector<float>(max_sequence_length * half_rotary_dim, 1.0f)); | ||
| test.AddInput<int64_t>("position_ids", {1}, {0}); | ||
| test.AddOutput<float>("output", {batch_size, sequence_length, hidden_size}, | ||
| std::vector<float>(hidden_size, 0.0f)); | ||
|
|
||
| std::vector<std::unique_ptr<IExecutionProvider>> execution_providers; | ||
| execution_providers.push_back(DefaultCpuExecutionProvider()); | ||
| test.Run(OpTester::ExpectResult::kExpectFailure, | ||
| "cos_cache dimension", {}, nullptr, &execution_providers); | ||
| } | ||
|
|
||
| } // namespace test | ||
| } // namespace onnxruntime | ||
Uh oh!
There was an error while loading. Please reload this page.