-
Notifications
You must be signed in to change notification settings - Fork 0
⚡ Thunderbolt: Softmax — Combine FMA and asymmetric unroll #43
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 all commits
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 |
|---|---|---|
|
|
@@ -332,6 +332,17 @@ class SoftmaxV5Benchmark : public SoftmaxBenchmark { | |
| }; | ||
| REGISTER_BENCHMARK(SoftmaxV5Benchmark); | ||
|
|
||
| class SoftmaxV6Benchmark : public SoftmaxBenchmark { | ||
| public: | ||
| const char *name() const override { return "softmax_v6"; } | ||
|
|
||
| void run() override { | ||
| ml_kernels::softmax_v6(inputs_[current_idx_].data(), outputs_[current_idx_].data(), inputs_[0].size()); | ||
| current_idx_ = (current_idx_ + 1) % pool_size_; | ||
| } | ||
|
Comment on lines
+337
to
+342
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. Apply function-body brace style in new benchmark methods. The added As per coding guidelines, "Keep braces on their own lines for function bodies". 🤖 Prompt for AI Agents |
||
| }; | ||
| REGISTER_BENCHMARK(SoftmaxV6Benchmark); | ||
|
|
||
| } // namespace | ||
|
|
||
| int main(int argc, char **argv) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,11 +181,41 @@ void test_softmax_v5() { | |
| std::cout << "test_softmax_v5 passed!" << std::endl; | ||
| } | ||
|
|
||
| void test_softmax_v6() { | ||
| std::cout << "Running test_softmax_v6..." << std::endl; | ||
| std::vector<float> input = { | ||
| -2.0f, -0.5f, 1.0f, 3.0f, | ||
| 0.0f, 0.0f, 0.0f, 0.0f, | ||
| 100.0f, 100.0f, -100.0f, -100.0f, | ||
| 5.0f, -5.0f, 2.0f, -2.0f, | ||
| 1.1f, 1.2f, 1.3f, 1.4f, | ||
| -1.1f, -1.2f, -1.3f, -1.4f, | ||
| 10.0f, 20.0f, 30.0f, 40.0f, | ||
| -10.0f, -20.0f, -30.0f, -40.0f | ||
| }; | ||
|
|
||
| std::vector<float> output_naive(input.size(), 0.0f); | ||
| std::vector<float> output_v6(input.size(), 0.0f); | ||
|
|
||
| ml_kernels::softmax_naive(input.data(), output_naive.data(), input.size()); | ||
| ml_kernels::softmax_v6(input.data(), output_v6.data(), input.size()); | ||
|
|
||
| float sum = 0.0f; | ||
| for (std::size_t i = 0; i < input.size(); ++i) { | ||
| assert(std::fabs(output_naive[i] - output_v6[i]) < 1e-4f); | ||
| sum += output_v6[i]; | ||
| } | ||
| assert(std::fabs(sum - 1.0f) < 1e-4f); | ||
|
|
||
| std::cout << "test_softmax_v6 passed!" << std::endl; | ||
| } | ||
|
Comment on lines
+184
to
+211
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. Use project brace style for the new test function definition.
As per coding guidelines, "Keep braces on their own lines for function bodies". 🤖 Prompt for AI Agents |
||
|
|
||
| int main() { | ||
| test_relu_naive(); | ||
| test_max_naive(); | ||
| test_softmax_v3(); | ||
| test_softmax_v4(); | ||
| test_softmax_v5(); | ||
| test_softmax_v6(); | ||
| std::cout << "All tests passed successfully!" << std::endl; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move function opening braces to their own lines in new kernels.
Both newly added function definitions place
{on the same line as the signature; this violates the project’s C/C++ function-body brace style.As per coding guidelines, "Keep braces on their own lines for function bodies".
Also applies to: 433-556
🤖 Prompt for AI Agents