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

[WIP] DecoderMaskedMultiHeadAttention CPU kernel. #22292

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mindest
Copy link
Contributor

@mindest mindest commented Oct 2, 2024

Description

DecoderMaskedMultiHeadAttention CPU kernel.


unit_cost.compute_cycles = static_cast<double>((SafeInt<ptrdiff_t>(2) * head_size - 1) * total_sequence_length);
unit_cost.bytes_loaded = static_cast<double>(SafeInt<ptrdiff_t>(2) * head_size * total_sequence_length * sizeof(T));
unit_cost.bytes_stored = static_cast<double>(head_size * total_sequence_length * sizeof(T));

Check warning

Code scanning / PREfast

Arithmetic overflow: Using operator '' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '' to avoid overflow (io.2). Warning

Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).

unit_cost.compute_cycles = static_cast<double>((SafeInt<ptrdiff_t>(2) * head_size - 1) * total_sequence_length);
unit_cost.bytes_loaded = static_cast<double>(SafeInt<ptrdiff_t>(2) * head_size * total_sequence_length * sizeof(T));
unit_cost.bytes_stored = static_cast<double>(head_size * total_sequence_length * sizeof(T));

Check warning

Code scanning / PREfast

Arithmetic overflow: Using operator '' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '' to avoid overflow (io.2). Warning

Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
unit_cost.bytes_stored = static_cast<double>(head_size * total_sequence_length * sizeof(T));

if (attn_bias_data != nullptr) {
unit_cost.bytes_loaded += probs_matrix_bytes * 2;

Check warning

Code scanning / PREfast

Arithmetic overflow: Using operator '' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '' to avoid overflow (io.2). Warning

Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).

math::Scale<T, CPUMathUtil>(v_head_size,
static_cast<float>(*attn_probs_ptr),
past_value_vec + j * v_head_size,

Check warning

Code scanning / PREfast

Arithmetic overflow: Using operator '' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '' to avoid overflow (io.2). Warning

Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2).
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.

1 participant