Refine Mod CPU implement
The Cytnx arithmetic implementation contained lots duplicated code across different type combinations, which caused:
- Difficult maintenance when updating logic
- Low code readability due to repetitive patterns
This PR refines the Mod CPU implementation, similar to https://github.com/Cytnx-dev/Cytnx/pull/651. Our goal is to generalize all arithmetic operations using templates, and eventually refactor the multiple-dispatch mechanism for arithmetic.
template <typename TLin, typename TRin>
void ArithmeticInternalImpl(...) {
if (type == 0)
cytnx::linalg_internal::AddInternalImpl<TLin, TRin>(
out, Lin, Rin, len, shape, invmapper_L, invmapper_R);
else if (type == 1)
cytnx::linalg_internal::MulInternalImpl<TLin, TRin>(
out, Lin, Rin, len, shape, invmapper_L, invmapper_R);
else if (type == 2)
// ...
else
// ...
}
Next, we plan to replace the linalg_internal::lii.Ari_ii usage in arithmetic .cpp files with the std::variant + std::visit pattern, similar to what we did in commit 710c98c.
I will refine src/backend/linalg_internal_cpu/Arithmetic_internal.cpp in next PR.
Codecov Report
:x: Patch coverage is 3.68852% with 235 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 31.99%. Comparing base (cc12e63) to head (4d95705).
:warning: Report is 15 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #704 +/- ##
==========================================
+ Coverage 30.19% 31.99% +1.79%
==========================================
Files 215 215
Lines 38332 36192 -2140
Branches 15471 14520 -951
==========================================
+ Hits 11576 11578 +2
+ Misses 24855 22713 -2142
Partials 1901 1901
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Hi @IvanaGyro, We can pass CI now. Could you take a look? Thx.