react-native-executorch 0.10.5 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/android/build.gradle.kts +4 -3
- package/ios/RnExecutorch.mm +15 -17
- package/lib/module/fetcher/fetcher.js +35 -122
- package/lib/module/fetcher/fetcher.js.map +1 -1
- package/lib/module/fetcher/telemetry.js +1 -1
- package/lib/module/index.js +12 -13
- package/lib/module/index.js.map +1 -1
- package/lib/module/models.js +4 -2
- package/lib/module/models.js.map +1 -1
- package/lib/typescript/src/fetcher/fetcher.d.ts +3 -7
- package/lib/typescript/src/fetcher/fetcher.d.ts.map +1 -1
- package/lib/typescript/src/models.d.ts.map +1 -1
- package/package.json +9 -7
- package/react-native-executorch.podspec +6 -2
- package/src/fetcher/fetcher.ts +38 -131
- package/src/fetcher/telemetry.ts +1 -1
- package/src/models.ts +6 -1
- package/third-party/common/phonemis/CMakeLists.txt +70 -14
- package/third-party/common/phonemis/README.md +183 -33
- package/third-party/common/phonemis/THIRD_PARTY_NOTICES.md +57 -0
- package/third-party/common/phonemis/knowledge/code_style.md +642 -0
- package/third-party/common/phonemis/licenses/Unicode-3.0.txt +39 -0
- package/third-party/common/phonemis/licenses/misaki-Apache-2.0.txt +201 -0
- package/third-party/common/phonemis/licenses/nlohmann-json-MIT.txt +21 -0
- package/third-party/common/phonemis/licenses/xsimd-BSD-3-Clause.txt +29 -0
- package/third-party/common/phonemis/src/phonemis/base/config.h +6 -0
- package/third-party/common/phonemis/src/phonemis/base/ipipeline.cpp +75 -0
- package/third-party/common/phonemis/src/phonemis/base/ipipeline.h +21 -0
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/constants.h +2 -5
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/lexicon_phonemizer.cpp +3 -4
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/neural_phonemizer.cpp +17 -8
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/neural_phonemizer.h +4 -0
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/tokenizer.cpp +21 -6
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/tokenizer.h +13 -4
- package/third-party/common/phonemis/src/phonemis/base/pipeline.cpp +8 -0
- package/third-party/common/phonemis/src/phonemis/base/pipeline.h +19 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/conditions.cpp +37 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/conditions.h +45 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/constants.h +10 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/context.cpp +105 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/context.h +49 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/document.cpp +173 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/document.h +67 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/text.cpp +75 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/text.h +60 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/types.h +18 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/config.h +53 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layer.h +9 -7
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/constants.h +20 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/layer.cpp +89 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/layer.h +35 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/types.h +16 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/kind.h +40 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/layer.h +382 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/notation.h +30 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/numerals.cpp +51 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/numerals.h +31 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern.h +30 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern_set.cpp +17 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern_set.h +31 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/patterns.cpp +811 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/patterns.h +285 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/primitives.cpp +64 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/primitives.h +23 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/types.h +94 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/sanitizer/layer.cpp +19 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/{sanitizer_layer.h → layers/sanitizer/layer.h} +8 -8
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/sym2word/layer.cpp +65 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/sym2word/layer.h +29 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/layer.cpp +170 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/layer.h +40 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/types.h +25 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/trim/layer.cpp +47 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/trim/layer.h +19 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/preprocessor.cpp +60 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/preprocessor.h +45 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/processor.cpp +6 -7
- package/third-party/common/phonemis/src/phonemis/base/processor/processor.h +14 -10
- package/third-party/common/phonemis/src/phonemis/base/tagger/hmm_tagger.cpp +89 -52
- package/third-party/common/phonemis/src/phonemis/base/tagger/hmm_tagger.h +16 -9
- package/third-party/common/phonemis/src/phonemis/base/tokenizer/tokenizer.cpp +13 -12
- package/third-party/common/phonemis/src/phonemis/lang/de/constants.h +183 -19
- package/third-party/common/phonemis/src/phonemis/lang/de/num2word.cpp +355 -309
- package/third-party/common/phonemis/src/phonemis/lang/de/num2word.h +42 -17
- package/third-party/common/phonemis/src/phonemis/lang/de/patterns.cpp +56 -0
- package/third-party/common/phonemis/src/phonemis/lang/de/patterns.h +15 -0
- package/third-party/common/phonemis/src/phonemis/lang/de/pipeline.h +3 -3
- package/third-party/common/phonemis/src/phonemis/lang/en/constants.h +181 -30
- package/third-party/common/phonemis/src/phonemis/lang/en/hmm_tagger.cpp +5 -7
- package/third-party/common/phonemis/src/phonemis/lang/en/num2word.cpp +232 -135
- package/third-party/common/phonemis/src/phonemis/lang/en/num2word.h +41 -16
- package/third-party/common/phonemis/src/phonemis/lang/en/pipeline.h +3 -10
- package/third-party/common/phonemis/src/phonemis/lang/es/constants.h +182 -60
- package/third-party/common/phonemis/src/phonemis/lang/es/num2word.cpp +247 -212
- package/third-party/common/phonemis/src/phonemis/lang/es/num2word.h +38 -18
- package/third-party/common/phonemis/src/phonemis/lang/es/patterns.cpp +50 -0
- package/third-party/common/phonemis/src/phonemis/lang/es/patterns.h +15 -0
- package/third-party/common/phonemis/src/phonemis/lang/es/pipeline.h +3 -3
- package/third-party/common/phonemis/src/phonemis/lang/fr/constants.h +152 -26
- package/third-party/common/phonemis/src/phonemis/lang/fr/num2word.cpp +252 -179
- package/third-party/common/phonemis/src/phonemis/lang/fr/num2word.h +38 -15
- package/third-party/common/phonemis/src/phonemis/lang/fr/patterns.cpp +83 -0
- package/third-party/common/phonemis/src/phonemis/lang/fr/patterns.h +15 -0
- package/third-party/common/phonemis/src/phonemis/lang/fr/pipeline.h +3 -3
- package/third-party/common/phonemis/src/phonemis/lang/hi/constants.h +62 -10
- package/third-party/common/phonemis/src/phonemis/lang/hi/num2word.cpp +74 -123
- package/third-party/common/phonemis/src/phonemis/lang/hi/num2word.h +27 -16
- package/third-party/common/phonemis/src/phonemis/lang/hi/pipeline.h +5 -3
- package/third-party/common/phonemis/src/phonemis/lang/it/constants.h +122 -42
- package/third-party/common/phonemis/src/phonemis/lang/it/num2word.cpp +200 -207
- package/third-party/common/phonemis/src/phonemis/lang/it/num2word.h +30 -18
- package/third-party/common/phonemis/src/phonemis/lang/it/patterns.cpp +25 -0
- package/third-party/common/phonemis/src/phonemis/lang/it/patterns.h +15 -0
- package/third-party/common/phonemis/src/phonemis/lang/it/pipeline.h +3 -3
- package/third-party/common/phonemis/src/phonemis/lang/pl/constants.h +346 -77
- package/third-party/common/phonemis/src/phonemis/lang/pl/num2word.cpp +631 -246
- package/third-party/common/phonemis/src/phonemis/lang/pl/num2word.h +47 -15
- package/third-party/common/phonemis/src/phonemis/lang/pl/pipeline.h +6 -6
- package/third-party/common/phonemis/src/phonemis/lang/pt/constants.h +201 -0
- package/third-party/common/phonemis/src/phonemis/lang/pt/num2word.cpp +365 -0
- package/third-party/common/phonemis/src/phonemis/lang/pt/num2word.h +53 -0
- package/third-party/common/phonemis/src/phonemis/lang/pt/pipeline.h +4 -2
- package/third-party/common/phonemis/src/phonemis/main.cpp +42 -11
- package/third-party/common/phonemis/src/phonemis/protophone/meta.h +24 -0
- package/third-party/common/phonemis/src/phonemis/protophone/numeric.h +26 -0
- package/third-party/common/phonemis/src/phonemis/protophone/protophone.cpp +525 -0
- package/third-party/common/phonemis/src/phonemis/protophone/protophone.h +80 -0
- package/third-party/common/phonemis/src/phonemis/protophone/tensor.h +76 -0
- package/third-party/common/phonemis/src/phonemis/protophone/tensor_utils.h +89 -0
- package/third-party/common/phonemis/src/phonemis/protophone/tensor_view.h +125 -0
- package/third-party/common/phonemis/src/phonemis/protophone/types.h +43 -0
- package/third-party/common/phonemis/src/phonemis/utils/strings.h +20 -14
- package/third-party/common/phonemis/src/phonemis/utils/unicode.h +15 -1
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_bit.hpp +232 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_details.hpp +386 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/utils/shifts.hpp +82 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx.hpp +2111 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx2.hpp +1591 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx2_128.hpp +170 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512bw.hpp +724 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512cd.hpp +28 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512dq.hpp +270 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512er.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512f.hpp +2919 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512pf.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx_128.hpp +164 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avxvnni.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_common.hpp +26 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_common_fwd.hpp +127 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_constants.hpp +393 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_emulated.hpp +787 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma4.hpp +92 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_isa.hpp +148 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_neon.hpp +3580 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_neon64.hpp +1614 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_rvv.hpp +1515 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_scalar.hpp +1210 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse2.hpp +2333 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse3.hpp +66 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse4_1.hpp +510 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse4_2.hpp +44 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_ssse3.hpp +186 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sve.hpp +1186 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_vsx.hpp +947 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_vxe.hpp +787 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_wasm.hpp +1819 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_arch.hpp +242 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_config.hpp +633 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_x86.hpp +1121 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpuid.hpp +144 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_getauxval.hpp +159 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_macros.hpp +78 -0
- package/third-party/common/phonemis/src/third-party/xsimd/math/xsimd_rem_pio2.hpp +707 -0
- package/third-party/common/phonemis/src/third-party/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
- package/third-party/common/phonemis/src/third-party/xsimd/memory/xsimd_alignment.hpp +102 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_all_registers.hpp +57 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_api.hpp +3106 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx2_register.hpp +57 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512er_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512f_register.hpp +77 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx_register.hpp +79 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch.hpp +1666 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch_constant.hpp +572 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch_fwd.hpp +41 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_common_arch.hpp +49 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_emulated_register.hpp +80 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma4_register.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_neon64_register.hpp +55 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_neon_register.hpp +130 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_register.hpp +96 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_rvv_register.hpp +491 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse2_register.hpp +59 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse3_register.hpp +49 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_ssse3_register.hpp +48 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sve_register.hpp +216 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_traits.hpp +409 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_utils.hpp +462 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_vsx_register.hpp +84 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_vxe_register.hpp +86 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_wasm_register.hpp +59 -0
- package/third-party/common/phonemis/src/third-party/xsimd/utils/bits.hpp +122 -0
- package/third-party/common/phonemis/src/third-party/xsimd/utils/xsimd_type_traits.hpp +145 -0
- package/third-party/common/phonemis/src/third-party/xsimd/xsimd.hpp +43 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/constants.h +0 -11
- package/third-party/common/phonemis/src/phonemis/base/processor/num2word/config.h +0 -16
- package/third-party/common/phonemis/src/phonemis/base/processor/num2word/layer.cpp +0 -271
- package/third-party/common/phonemis/src/phonemis/base/processor/num2word/layer.h +0 -45
- package/third-party/common/phonemis/src/phonemis/base/processor/num2word/types.h +0 -29
- package/third-party/common/phonemis/src/phonemis/base/processor/sanitizer_layer.cpp +0 -22
- package/third-party/common/phonemis/src/phonemis/base/processor/trim_layer.cpp +0 -40
- package/third-party/common/phonemis/src/phonemis/base/processor/trim_layer.h +0 -22
|
@@ -0,0 +1,1006 @@
|
|
|
1
|
+
/***************************************************************************
|
|
2
|
+
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
|
|
3
|
+
* Martin Renou *
|
|
4
|
+
* Copyright (c) QuantStack *
|
|
5
|
+
* Copyright (c) Serge Guelton *
|
|
6
|
+
* *
|
|
7
|
+
* Distributed under the terms of the BSD 3-Clause License. *
|
|
8
|
+
* *
|
|
9
|
+
* The full license is in the file LICENSE, distributed with this software. *
|
|
10
|
+
****************************************************************************/
|
|
11
|
+
|
|
12
|
+
#ifndef XSIMD_COMMON_MEMORY_HPP
|
|
13
|
+
#define XSIMD_COMMON_MEMORY_HPP
|
|
14
|
+
|
|
15
|
+
#include <algorithm>
|
|
16
|
+
#include <array>
|
|
17
|
+
#include <complex>
|
|
18
|
+
|
|
19
|
+
#include "../../types/xsimd_batch_constant.hpp"
|
|
20
|
+
#include "./xsimd_common_details.hpp"
|
|
21
|
+
|
|
22
|
+
namespace xsimd
|
|
23
|
+
{
|
|
24
|
+
template <typename T, class A, T... Values>
|
|
25
|
+
struct batch_constant;
|
|
26
|
+
|
|
27
|
+
template <typename T, class A, bool... Values>
|
|
28
|
+
struct batch_bool_constant;
|
|
29
|
+
|
|
30
|
+
namespace kernel
|
|
31
|
+
{
|
|
32
|
+
|
|
33
|
+
using namespace types;
|
|
34
|
+
|
|
35
|
+
// broadcast
|
|
36
|
+
namespace detail
|
|
37
|
+
{
|
|
38
|
+
template <class T, class A>
|
|
39
|
+
struct broadcaster
|
|
40
|
+
{
|
|
41
|
+
using return_type = batch<T, A>;
|
|
42
|
+
|
|
43
|
+
static XSIMD_INLINE return_type run(T v) noexcept
|
|
44
|
+
{
|
|
45
|
+
return return_type::broadcast(v);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
template <class A>
|
|
50
|
+
struct broadcaster<bool, A>
|
|
51
|
+
{
|
|
52
|
+
using return_type = batch_bool<xsimd::as_unsigned_integer_t<bool>, A>;
|
|
53
|
+
|
|
54
|
+
static XSIMD_INLINE return_type run(bool b) noexcept
|
|
55
|
+
{
|
|
56
|
+
return return_type(b);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// compress
|
|
62
|
+
namespace detail
|
|
63
|
+
{
|
|
64
|
+
template <class IT, class A, class I, size_t... Is>
|
|
65
|
+
XSIMD_INLINE batch<IT, A> create_compress_swizzle_mask(I bitmask, std::index_sequence<Is...>)
|
|
66
|
+
{
|
|
67
|
+
batch<IT, A> swizzle_mask(IT(0));
|
|
68
|
+
alignas(A::alignment()) IT mask_buffer[batch<IT, A>::size] = { Is... };
|
|
69
|
+
size_t inserted = 0;
|
|
70
|
+
for (size_t i = 0; i < sizeof...(Is); ++i)
|
|
71
|
+
if ((bitmask >> i) & 1u)
|
|
72
|
+
std::swap(mask_buffer[inserted++], mask_buffer[i]);
|
|
73
|
+
return batch<IT, A>::load_aligned(&mask_buffer[0]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
template <typename A, typename T>
|
|
78
|
+
XSIMD_INLINE batch<T, A>
|
|
79
|
+
compress(batch<T, A> const& x, batch_bool<T, A> const& mask,
|
|
80
|
+
kernel::requires_arch<common>) noexcept
|
|
81
|
+
{
|
|
82
|
+
using IT = as_unsigned_integer_t<T>;
|
|
83
|
+
constexpr std::size_t size = batch_bool<T, A>::size;
|
|
84
|
+
auto bitmask = mask.mask();
|
|
85
|
+
auto z = select(mask, x, batch<T, A>((T)0));
|
|
86
|
+
auto compress_mask = detail::create_compress_swizzle_mask<IT, A>(bitmask, std::make_index_sequence<size>());
|
|
87
|
+
return swizzle(z, compress_mask);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// expand
|
|
91
|
+
template <typename A, typename T>
|
|
92
|
+
XSIMD_INLINE batch<T, A>
|
|
93
|
+
expand(batch<T, A> const& x, batch_bool<T, A> const& mask,
|
|
94
|
+
kernel::requires_arch<common>) noexcept
|
|
95
|
+
{
|
|
96
|
+
constexpr auto size = batch<T, A>::size;
|
|
97
|
+
alignas(A::alignment()) T x_in[size], x_out[size] = { T() };
|
|
98
|
+
x.store_aligned(x_in);
|
|
99
|
+
int i = 0, j = 0;
|
|
100
|
+
for (auto bitmask = mask.mask(); bitmask; bitmask >>= 1, ++i)
|
|
101
|
+
{
|
|
102
|
+
if (bitmask & 1)
|
|
103
|
+
x_out[i] = x_in[j++];
|
|
104
|
+
}
|
|
105
|
+
return xsimd::batch<T, A>::load_aligned(x_out);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// extract_pair
|
|
109
|
+
template <class A, class T>
|
|
110
|
+
XSIMD_INLINE batch<T, A> extract_pair(batch<T, A> const& self, batch<T, A> const& other, std::size_t i, requires_arch<common>) noexcept
|
|
111
|
+
{
|
|
112
|
+
constexpr std::size_t size = batch<T, A>::size;
|
|
113
|
+
assert(i < size && "index in bounds");
|
|
114
|
+
|
|
115
|
+
alignas(A::alignment()) T self_buffer[size];
|
|
116
|
+
self.store_aligned(self_buffer);
|
|
117
|
+
|
|
118
|
+
alignas(A::alignment()) T other_buffer[size];
|
|
119
|
+
other.store_aligned(other_buffer);
|
|
120
|
+
|
|
121
|
+
alignas(A::alignment()) T concat_buffer[size];
|
|
122
|
+
|
|
123
|
+
for (std::size_t j = 0; j < (size - i); ++j)
|
|
124
|
+
{
|
|
125
|
+
concat_buffer[j] = other_buffer[i + j];
|
|
126
|
+
if (j < i)
|
|
127
|
+
{
|
|
128
|
+
concat_buffer[size - 1 - j] = self_buffer[i - 1 - j];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return batch<T, A>::load_aligned(concat_buffer);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// gather
|
|
135
|
+
namespace detail
|
|
136
|
+
{
|
|
137
|
+
// Not using XSIMD_INLINE here as it makes msvc hand got ever on avx512
|
|
138
|
+
template <size_t N, typename T, typename A, typename U, typename V, std::enable_if_t<N == 0, int> = 0>
|
|
139
|
+
inline batch<T, A> gather(U const* src, batch<V, A> const& index,
|
|
140
|
+
::xsimd::index<N> I) noexcept
|
|
141
|
+
{
|
|
142
|
+
return insert(batch<T, A> {}, static_cast<T>(src[index.get(I)]), I);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
template <size_t N, typename T, typename A, typename U, typename V, std::enable_if_t<N != 0, int> = 0>
|
|
146
|
+
inline batch<T, A>
|
|
147
|
+
gather(U const* src, batch<V, A> const& index, ::xsimd::index<N> I) noexcept
|
|
148
|
+
{
|
|
149
|
+
static_assert(N <= batch<V, A>::size, "Incorrect value in recursion!");
|
|
150
|
+
|
|
151
|
+
const auto test = gather<N - 1, T, A>(src, index, {});
|
|
152
|
+
return insert(test, static_cast<T>(src[index.get(I)]), I);
|
|
153
|
+
}
|
|
154
|
+
} // namespace detail
|
|
155
|
+
|
|
156
|
+
template <typename T, typename A, typename V>
|
|
157
|
+
XSIMD_INLINE batch<T, A>
|
|
158
|
+
gather(batch<T, A> const&, T const* src, batch<V, A> const& index,
|
|
159
|
+
kernel::requires_arch<common>) noexcept
|
|
160
|
+
{
|
|
161
|
+
static_assert(batch<T, A>::size == batch<V, A>::size,
|
|
162
|
+
"Index and destination sizes must match");
|
|
163
|
+
|
|
164
|
+
return detail::gather<batch<V, A>::size - 1, T, A>(src, index, {});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Gather with runtime indexes and mismatched strides.
|
|
168
|
+
template <typename T, typename A, typename U, typename V>
|
|
169
|
+
XSIMD_INLINE detail::sizes_mismatch_t<T, U, batch<T, A>>
|
|
170
|
+
gather(batch<T, A> const&, U const* src, batch<V, A> const& index,
|
|
171
|
+
kernel::requires_arch<common>) noexcept
|
|
172
|
+
{
|
|
173
|
+
static_assert(batch<T, A>::size == batch<V, A>::size,
|
|
174
|
+
"Index and destination sizes must match");
|
|
175
|
+
|
|
176
|
+
return detail::gather<batch<V, A>::size - 1, T, A>(src, index, {});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Gather with runtime indexes and matching strides.
|
|
180
|
+
template <typename T, typename A, typename U, typename V>
|
|
181
|
+
XSIMD_INLINE detail::stride_match_t<T, U, batch<T, A>>
|
|
182
|
+
gather(batch<T, A> const&, U const* src, batch<V, A> const& index,
|
|
183
|
+
kernel::requires_arch<common>) noexcept
|
|
184
|
+
{
|
|
185
|
+
static_assert(batch<T, A>::size == batch<V, A>::size,
|
|
186
|
+
"Index and destination sizes must match");
|
|
187
|
+
|
|
188
|
+
return batch_cast<T>(kernel::gather(batch<U, A> {}, src, index, A {}));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// insert
|
|
192
|
+
template <class A, class T, size_t I>
|
|
193
|
+
XSIMD_INLINE batch<T, A> insert(batch<T, A> const& self, T val, index<I>, requires_arch<common>) noexcept
|
|
194
|
+
{
|
|
195
|
+
struct index_mask
|
|
196
|
+
{
|
|
197
|
+
static constexpr bool get(size_t index, size_t /* size*/)
|
|
198
|
+
{
|
|
199
|
+
return index != I;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
batch<T, A> tmp(val);
|
|
203
|
+
return select(make_batch_bool_constant<T, index_mask, A>(), self, tmp);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// get
|
|
207
|
+
template <class A, size_t I, class T>
|
|
208
|
+
XSIMD_INLINE T get(batch<T, A> const& self, ::xsimd::index<I>, requires_arch<common>) noexcept
|
|
209
|
+
{
|
|
210
|
+
alignas(A::alignment()) T buffer[batch<T, A>::size];
|
|
211
|
+
self.store_aligned(&buffer[0]);
|
|
212
|
+
return buffer[I];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
template <class A, size_t I, class T>
|
|
216
|
+
XSIMD_INLINE T get(batch_bool<T, A> const& self, ::xsimd::index<I>, requires_arch<common>) noexcept
|
|
217
|
+
{
|
|
218
|
+
alignas(A::alignment()) T buffer[batch_bool<T, A>::size];
|
|
219
|
+
self.store_aligned(&buffer[0]);
|
|
220
|
+
return buffer[I];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
template <class A, size_t I, class T>
|
|
224
|
+
XSIMD_INLINE typename batch<std::complex<T>, A>::value_type get(batch<std::complex<T>, A> const& self, ::xsimd::index<I>, requires_arch<common>) noexcept
|
|
225
|
+
{
|
|
226
|
+
using value_type = typename batch<std::complex<T>, A>::value_type;
|
|
227
|
+
alignas(A::alignment()) value_type buffer[batch<std::complex<T>, A>::size];
|
|
228
|
+
self.store_aligned(&buffer[0]);
|
|
229
|
+
return buffer[I];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
template <class A, class T>
|
|
233
|
+
XSIMD_INLINE T get(batch<T, A> const& self, std::size_t i, requires_arch<common>) noexcept
|
|
234
|
+
{
|
|
235
|
+
alignas(A::alignment()) T buffer[batch<T, A>::size];
|
|
236
|
+
self.store_aligned(&buffer[0]);
|
|
237
|
+
return buffer[i];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
template <class A, class T>
|
|
241
|
+
XSIMD_INLINE T get(batch_bool<T, A> const& self, std::size_t i, requires_arch<common>) noexcept
|
|
242
|
+
{
|
|
243
|
+
alignas(A::alignment()) bool buffer[batch_bool<T, A>::size];
|
|
244
|
+
self.store_aligned(&buffer[0]);
|
|
245
|
+
return buffer[i];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
template <class A, class T>
|
|
249
|
+
XSIMD_INLINE typename batch<std::complex<T>, A>::value_type get(batch<std::complex<T>, A> const& self, std::size_t i, requires_arch<common>) noexcept
|
|
250
|
+
{
|
|
251
|
+
using T2 = typename batch<std::complex<T>, A>::value_type;
|
|
252
|
+
alignas(A::alignment()) T2 buffer[batch<std::complex<T>, A>::size];
|
|
253
|
+
self.store_aligned(&buffer[0]);
|
|
254
|
+
return buffer[i];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// first
|
|
258
|
+
template <class A, class T>
|
|
259
|
+
XSIMD_INLINE T first(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
260
|
+
{
|
|
261
|
+
return get(self, 0, common {});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
template <class A, class T>
|
|
265
|
+
XSIMD_INLINE T first(batch_bool<T, A> const& self, requires_arch<common>) noexcept
|
|
266
|
+
{
|
|
267
|
+
return first(batch<T, A>(self), A {});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
template <class A, class T>
|
|
271
|
+
XSIMD_INLINE typename batch<std::complex<T>, A>::value_type first(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept
|
|
272
|
+
{
|
|
273
|
+
return { first(self.real(), A {}), first(self.imag(), A {}) };
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// load
|
|
277
|
+
template <class A, class T>
|
|
278
|
+
XSIMD_INLINE batch_bool<T, A> load_unaligned(bool const* mem, batch_bool<T, A>, requires_arch<common>) noexcept
|
|
279
|
+
{
|
|
280
|
+
using batch_type = batch<T, A>;
|
|
281
|
+
batch_type ref(0);
|
|
282
|
+
constexpr auto size = batch_bool<T, A>::size;
|
|
283
|
+
alignas(A::alignment()) T buffer[size];
|
|
284
|
+
for (std::size_t i = 0; i < size; ++i)
|
|
285
|
+
buffer[i] = mem[i] ? 1 : 0;
|
|
286
|
+
return ref != batch_type::load_aligned(&buffer[0]);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
template <class A, class T>
|
|
290
|
+
XSIMD_INLINE batch_bool<T, A> load_aligned(bool const* mem, batch_bool<T, A> b, requires_arch<common>) noexcept
|
|
291
|
+
{
|
|
292
|
+
return load_unaligned(mem, b, A {});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
template <class A, class T>
|
|
296
|
+
XSIMD_INLINE batch_bool<T, A> load_stream(bool const* mem, batch_bool<T, A> b, requires_arch<common>) noexcept
|
|
297
|
+
{
|
|
298
|
+
return load_aligned(mem, b, A {});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// load_aligned
|
|
302
|
+
namespace detail
|
|
303
|
+
{
|
|
304
|
+
template <class A, class T_in, class T_out>
|
|
305
|
+
XSIMD_INLINE batch<T_out, A> load_aligned(T_in const* mem, convert<T_out>, requires_arch<common>, with_fast_conversion) noexcept
|
|
306
|
+
{
|
|
307
|
+
using batch_type_in = batch<T_in, A>;
|
|
308
|
+
using batch_type_out = batch<T_out, A>;
|
|
309
|
+
return fast_cast(batch_type_in::load_aligned(mem), batch_type_out(), A {});
|
|
310
|
+
}
|
|
311
|
+
template <class A, class T_in, class T_out>
|
|
312
|
+
XSIMD_INLINE batch<T_out, A> load_aligned(T_in const* mem, convert<T_out>, requires_arch<common>, with_slow_conversion) noexcept
|
|
313
|
+
{
|
|
314
|
+
static_assert(!std::is_same<T_in, T_out>::value, "there should be a direct load for this type combination");
|
|
315
|
+
using batch_type_out = batch<T_out, A>;
|
|
316
|
+
alignas(A::alignment()) T_out buffer[batch_type_out::size];
|
|
317
|
+
std::copy(mem, mem + batch_type_out::size, std::begin(buffer));
|
|
318
|
+
return batch_type_out::load_aligned(buffer);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
template <class A, class T_in, class T_out>
|
|
322
|
+
XSIMD_INLINE batch<T_out, A> load_aligned(T_in const* mem, convert<T_out> cvt, requires_arch<common>) noexcept
|
|
323
|
+
{
|
|
324
|
+
return detail::load_aligned<A>(mem, cvt, A {}, detail::conversion_type<A, T_in, T_out> {});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// load_unaligned
|
|
328
|
+
namespace detail
|
|
329
|
+
{
|
|
330
|
+
template <class A, class T_in, class T_out>
|
|
331
|
+
XSIMD_INLINE batch<T_out, A> load_unaligned(T_in const* mem, convert<T_out>, requires_arch<common>, with_fast_conversion) noexcept
|
|
332
|
+
{
|
|
333
|
+
using batch_type_in = batch<T_in, A>;
|
|
334
|
+
using batch_type_out = batch<T_out, A>;
|
|
335
|
+
return fast_cast(batch_type_in::load_unaligned(mem), batch_type_out(), A {});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
template <class A, class T_in, class T_out>
|
|
339
|
+
XSIMD_INLINE batch<T_out, A> load_unaligned(T_in const* mem, convert<T_out> cvt, requires_arch<common>, with_slow_conversion) noexcept
|
|
340
|
+
{
|
|
341
|
+
static_assert(!std::is_same<T_in, T_out>::value, "there should be a direct load for this type combination");
|
|
342
|
+
return load_aligned<A>(mem, cvt, common {}, with_slow_conversion {});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
template <class A, class T_in, class T_out>
|
|
346
|
+
XSIMD_INLINE batch<T_out, A> load_unaligned(T_in const* mem, convert<T_out> cvt, requires_arch<common>) noexcept
|
|
347
|
+
{
|
|
348
|
+
return detail::load_unaligned<A>(mem, cvt, common {}, detail::conversion_type<A, T_in, T_out> {});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
template <class A, class T>
|
|
352
|
+
XSIMD_INLINE batch<T, A> load(T const* mem, aligned_mode, requires_arch<A>) noexcept
|
|
353
|
+
{
|
|
354
|
+
return load_aligned<A>(mem, convert<T> {}, A {});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
template <class A, class T>
|
|
358
|
+
XSIMD_INLINE batch<T, A> load(T const* mem, unaligned_mode, requires_arch<A>) noexcept
|
|
359
|
+
{
|
|
360
|
+
return load_unaligned<A>(mem, convert<T> {}, A {});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
template <class A, class T_in, class T_out, bool... Values, class alignment>
|
|
364
|
+
XSIMD_INLINE batch<T_out, A>
|
|
365
|
+
load_masked(T_in const* mem, batch_bool_constant<T_out, A, Values...>, convert<T_out>, alignment, requires_arch<common>) noexcept
|
|
366
|
+
{
|
|
367
|
+
constexpr std::size_t size = batch<T_out, A>::size;
|
|
368
|
+
alignas(A::alignment()) std::array<T_out, size> buffer {};
|
|
369
|
+
constexpr bool mask[size] = { Values... };
|
|
370
|
+
|
|
371
|
+
for (std::size_t i = 0; i < size; ++i)
|
|
372
|
+
buffer[i] = mask[i] ? static_cast<T_out>(mem[i]) : T_out(0);
|
|
373
|
+
|
|
374
|
+
return batch<T_out, A>::load(buffer.data(), aligned_mode {});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
template <class A, class T_in, class T_out, bool... Values, class alignment>
|
|
378
|
+
XSIMD_INLINE void
|
|
379
|
+
store_masked(T_out* mem, batch<T_in, A> const& src, batch_bool_constant<T_in, A, Values...>, alignment, requires_arch<common>) noexcept
|
|
380
|
+
{
|
|
381
|
+
constexpr std::size_t size = batch<T_in, A>::size;
|
|
382
|
+
constexpr bool mask[size] = { Values... };
|
|
383
|
+
|
|
384
|
+
for (std::size_t i = 0; i < size; ++i)
|
|
385
|
+
if (mask[i])
|
|
386
|
+
{
|
|
387
|
+
mem[i] = static_cast<T_out>(src.get(i));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
template <class A, bool... Values, class Mode>
|
|
392
|
+
XSIMD_INLINE batch<int32_t, A> load_masked(int32_t const* mem, batch_bool_constant<int32_t, A, Values...>, convert<int32_t>, Mode, requires_arch<A>) noexcept
|
|
393
|
+
{
|
|
394
|
+
const auto f = load_masked<A>(reinterpret_cast<const float*>(mem), batch_bool_constant<float, A, Values...> {}, convert<float> {}, Mode {}, A {});
|
|
395
|
+
return bitwise_cast<int32_t>(f);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
template <class A, bool... Values, class Mode>
|
|
399
|
+
XSIMD_INLINE batch<uint32_t, A> load_masked(uint32_t const* mem, batch_bool_constant<uint32_t, A, Values...>, convert<uint32_t>, Mode, requires_arch<A>) noexcept
|
|
400
|
+
{
|
|
401
|
+
const auto f = load_masked<A>(reinterpret_cast<const float*>(mem), batch_bool_constant<float, A, Values...> {}, convert<float> {}, Mode {}, A {});
|
|
402
|
+
return bitwise_cast<uint32_t>(f);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
template <class A, bool... Values, class Mode>
|
|
406
|
+
XSIMD_INLINE std::enable_if_t<types::has_simd_register<double, A>::value, batch<int64_t, A>>
|
|
407
|
+
load_masked(int64_t const* mem, batch_bool_constant<int64_t, A, Values...>, convert<int64_t>, Mode, requires_arch<A>) noexcept
|
|
408
|
+
{
|
|
409
|
+
const auto d = load_masked<A>(reinterpret_cast<const double*>(mem), batch_bool_constant<double, A, Values...> {}, convert<double> {}, Mode {}, A {});
|
|
410
|
+
return bitwise_cast<int64_t>(d);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
template <class A, bool... Values, class Mode>
|
|
414
|
+
XSIMD_INLINE std::enable_if_t<types::has_simd_register<double, A>::value, batch<uint64_t, A>>
|
|
415
|
+
load_masked(uint64_t const* mem, batch_bool_constant<uint64_t, A, Values...>, convert<uint64_t>, Mode, requires_arch<A>) noexcept
|
|
416
|
+
{
|
|
417
|
+
const auto d = load_masked<A>(reinterpret_cast<const double*>(mem), batch_bool_constant<double, A, Values...> {}, convert<double> {}, Mode {}, A {});
|
|
418
|
+
return bitwise_cast<uint64_t>(d);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
template <class A, bool... Values, class Mode>
|
|
422
|
+
XSIMD_INLINE void store_masked(int32_t* mem, batch<int32_t, A> const& src, batch_bool_constant<int32_t, A, Values...>, Mode, requires_arch<A>) noexcept
|
|
423
|
+
{
|
|
424
|
+
store_masked<A>(reinterpret_cast<float*>(mem), bitwise_cast<float>(src), batch_bool_constant<float, A, Values...> {}, Mode {}, A {});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
template <class A, bool... Values, class Mode>
|
|
428
|
+
XSIMD_INLINE void store_masked(uint32_t* mem, batch<uint32_t, A> const& src, batch_bool_constant<uint32_t, A, Values...>, Mode, requires_arch<A>) noexcept
|
|
429
|
+
{
|
|
430
|
+
store_masked<A>(reinterpret_cast<float*>(mem), bitwise_cast<float>(src), batch_bool_constant<float, A, Values...> {}, Mode {}, A {});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
template <class A, bool... Values, class Mode>
|
|
434
|
+
XSIMD_INLINE std::enable_if_t<types::has_simd_register<double, A>::value>
|
|
435
|
+
store_masked(int64_t* mem, batch<int64_t, A> const& src, batch_bool_constant<int64_t, A, Values...>, Mode, requires_arch<A>) noexcept
|
|
436
|
+
{
|
|
437
|
+
store_masked<A>(reinterpret_cast<double*>(mem), bitwise_cast<double>(src), batch_bool_constant<double, A, Values...> {}, Mode {}, A {});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
template <class A, bool... Values, class Mode>
|
|
441
|
+
XSIMD_INLINE std::enable_if_t<types::has_simd_register<double, A>::value>
|
|
442
|
+
store_masked(uint64_t* mem, batch<uint64_t, A> const& src, batch_bool_constant<uint64_t, A, Values...>, Mode, requires_arch<A>) noexcept
|
|
443
|
+
{
|
|
444
|
+
store_masked<A>(reinterpret_cast<double*>(mem), bitwise_cast<double>(src), batch_bool_constant<double, A, Values...> {}, Mode {}, A {});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
template <class A, class T_in, class T_out>
|
|
448
|
+
XSIMD_INLINE batch<T_out, A> load_stream(T_in const* mem, convert<T_out> cvt, requires_arch<common>) noexcept
|
|
449
|
+
{
|
|
450
|
+
return load_aligned<A>(mem, cvt, A {});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// rotate_right
|
|
454
|
+
template <size_t N, class A, class T>
|
|
455
|
+
XSIMD_INLINE batch<T, A> rotate_right(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
456
|
+
{
|
|
457
|
+
struct rotate_generator
|
|
458
|
+
{
|
|
459
|
+
static constexpr size_t get(size_t index, size_t size)
|
|
460
|
+
{
|
|
461
|
+
return (index - N) % size;
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
return swizzle(self, make_batch_constant<as_unsigned_integer_t<T>, rotate_generator, A>());
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
template <size_t N, class A, class T>
|
|
469
|
+
XSIMD_INLINE batch<std::complex<T>, A> rotate_right(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept
|
|
470
|
+
{
|
|
471
|
+
return { rotate_right<N>(self.real()), rotate_right<N>(self.imag()) };
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// rotate_left
|
|
475
|
+
template <size_t N, class A, class T>
|
|
476
|
+
XSIMD_INLINE batch<T, A> rotate_left(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
477
|
+
{
|
|
478
|
+
struct rotate_generator
|
|
479
|
+
{
|
|
480
|
+
static constexpr size_t get(size_t index, size_t size)
|
|
481
|
+
{
|
|
482
|
+
return (index + N) % size;
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
return swizzle(self, make_batch_constant<as_unsigned_integer_t<T>, rotate_generator, A>());
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
template <size_t N, class A, class T>
|
|
490
|
+
XSIMD_INLINE batch<std::complex<T>, A> rotate_left(batch<std::complex<T>, A> const& self, requires_arch<common>) noexcept
|
|
491
|
+
{
|
|
492
|
+
return { rotate_left<N>(self.real()), rotate_left<N>(self.imag()) };
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// Scatter with runtime indexes.
|
|
496
|
+
namespace detail
|
|
497
|
+
{
|
|
498
|
+
template <size_t N, typename T, typename A, typename U, typename V, std::enable_if_t<N == 0, int> = 0>
|
|
499
|
+
XSIMD_INLINE void scatter(batch<T, A> const& src, U* dst,
|
|
500
|
+
batch<V, A> const& index,
|
|
501
|
+
::xsimd::index<N> I) noexcept
|
|
502
|
+
{
|
|
503
|
+
dst[index.get(I)] = static_cast<U>(src.get(I));
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
template <size_t N, typename T, typename A, typename U, typename V, std::enable_if_t<N != 0, int> = 0>
|
|
507
|
+
XSIMD_INLINE void
|
|
508
|
+
scatter(batch<T, A> const& src, U* dst, batch<V, A> const& index,
|
|
509
|
+
::xsimd::index<N> I) noexcept
|
|
510
|
+
{
|
|
511
|
+
static_assert(N <= batch<V, A>::size, "Incorrect value in recursion!");
|
|
512
|
+
|
|
513
|
+
kernel::detail::scatter<N - 1, T, A, U, V>(
|
|
514
|
+
src, dst, index, {});
|
|
515
|
+
dst[index.get(I)] = static_cast<U>(src.get(I));
|
|
516
|
+
}
|
|
517
|
+
} // namespace detail
|
|
518
|
+
|
|
519
|
+
template <typename A, typename T, typename V>
|
|
520
|
+
XSIMD_INLINE void
|
|
521
|
+
scatter(batch<T, A> const& src, T* dst,
|
|
522
|
+
batch<V, A> const& index,
|
|
523
|
+
kernel::requires_arch<common>) noexcept
|
|
524
|
+
{
|
|
525
|
+
static_assert(batch<T, A>::size == batch<V, A>::size,
|
|
526
|
+
"Source and index sizes must match");
|
|
527
|
+
kernel::detail::scatter<batch<V, A>::size - 1, T, A, T, V>(
|
|
528
|
+
src, dst, index, {});
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
template <typename A, typename T, typename U, typename V>
|
|
532
|
+
XSIMD_INLINE detail::sizes_mismatch_t<T, U, void>
|
|
533
|
+
scatter(batch<T, A> const& src, U* dst,
|
|
534
|
+
batch<V, A> const& index,
|
|
535
|
+
kernel::requires_arch<common>) noexcept
|
|
536
|
+
{
|
|
537
|
+
static_assert(batch<T, A>::size == batch<V, A>::size,
|
|
538
|
+
"Source and index sizes must match");
|
|
539
|
+
kernel::detail::scatter<batch<V, A>::size - 1, T, A, U, V>(
|
|
540
|
+
src, dst, index, {});
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
template <typename A, typename T, typename U, typename V>
|
|
544
|
+
XSIMD_INLINE detail::stride_match_t<T, U, void>
|
|
545
|
+
scatter(batch<T, A> const& src, U* dst,
|
|
546
|
+
batch<V, A> const& index,
|
|
547
|
+
kernel::requires_arch<common>) noexcept
|
|
548
|
+
{
|
|
549
|
+
static_assert(batch<T, A>::size == batch<V, A>::size,
|
|
550
|
+
"Source and index sizes must match");
|
|
551
|
+
const auto tmp = batch_cast<U>(src);
|
|
552
|
+
kernel::scatter<A>(tmp, dst, index, A {});
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// shuffle
|
|
556
|
+
namespace detail
|
|
557
|
+
{
|
|
558
|
+
constexpr bool is_swizzle_fst(size_t)
|
|
559
|
+
{
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
562
|
+
template <typename ITy, typename... ITys>
|
|
563
|
+
constexpr bool is_swizzle_fst(size_t bsize, ITy index, ITys... indices)
|
|
564
|
+
{
|
|
565
|
+
return index < bsize && is_swizzle_fst(bsize, indices...);
|
|
566
|
+
}
|
|
567
|
+
constexpr bool is_swizzle_snd(size_t)
|
|
568
|
+
{
|
|
569
|
+
return true;
|
|
570
|
+
}
|
|
571
|
+
template <typename ITy, typename... ITys>
|
|
572
|
+
constexpr bool is_swizzle_snd(size_t bsize, ITy index, ITys... indices)
|
|
573
|
+
{
|
|
574
|
+
return index >= bsize && is_swizzle_snd(bsize, indices...);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
constexpr bool is_zip_lo(size_t)
|
|
578
|
+
{
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
template <typename ITy>
|
|
583
|
+
constexpr bool is_zip_lo(size_t, ITy)
|
|
584
|
+
{
|
|
585
|
+
return false;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
template <typename ITy0, typename ITy1, typename... ITys>
|
|
589
|
+
constexpr bool is_zip_lo(size_t bsize, ITy0 index0, ITy1 index1, ITys... indices)
|
|
590
|
+
{
|
|
591
|
+
return index0 == (bsize - (sizeof...(indices) + 2)) && index1 == (2 * bsize - (sizeof...(indices) + 2)) && is_zip_lo(bsize, indices...);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
constexpr bool is_zip_hi(size_t)
|
|
595
|
+
{
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
template <typename ITy>
|
|
600
|
+
constexpr bool is_zip_hi(size_t, ITy)
|
|
601
|
+
{
|
|
602
|
+
return false;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
template <typename ITy0, typename ITy1, typename... ITys>
|
|
606
|
+
constexpr bool is_zip_hi(size_t bsize, ITy0 index0, ITy1 index1, ITys... indices)
|
|
607
|
+
{
|
|
608
|
+
return index0 == (bsize / 2 + bsize - (sizeof...(indices) + 2)) && index1 == (bsize / 2 + 2 * bsize - (sizeof...(indices) + 2)) && is_zip_hi(bsize, indices...);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
constexpr bool is_select(size_t)
|
|
612
|
+
{
|
|
613
|
+
return true;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
template <typename ITy, typename... ITys>
|
|
617
|
+
constexpr bool is_select(size_t bsize, ITy index, ITys... indices)
|
|
618
|
+
{
|
|
619
|
+
return (index < bsize ? index : index - bsize) == (bsize - sizeof...(ITys)) && is_select(bsize, indices...);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
template <class A, typename T, typename ITy, ITy... Indices>
|
|
625
|
+
XSIMD_INLINE batch<T, A> shuffle(batch<T, A> const& x, batch<T, A> const& y, batch_constant<ITy, A, Indices...>, requires_arch<common>) noexcept
|
|
626
|
+
{
|
|
627
|
+
constexpr size_t bsize = sizeof...(Indices);
|
|
628
|
+
static_assert(bsize == batch<T, A>::size, "valid shuffle");
|
|
629
|
+
|
|
630
|
+
// Detect common patterns
|
|
631
|
+
XSIMD_IF_CONSTEXPR(detail::is_swizzle_fst(bsize, Indices...))
|
|
632
|
+
{
|
|
633
|
+
return swizzle(x, batch_constant<ITy, A, ((Indices >= bsize) ? 0 /* never happens */ : Indices)...>());
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
XSIMD_IF_CONSTEXPR(detail::is_swizzle_snd(bsize, Indices...))
|
|
637
|
+
{
|
|
638
|
+
return swizzle(y, batch_constant<ITy, A, ((Indices >= bsize) ? (Indices - bsize) : 0 /* never happens */)...>());
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
XSIMD_IF_CONSTEXPR(detail::is_zip_lo(bsize, Indices...))
|
|
642
|
+
{
|
|
643
|
+
return zip_lo(x, y);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
XSIMD_IF_CONSTEXPR(detail::is_zip_hi(bsize, Indices...))
|
|
647
|
+
{
|
|
648
|
+
return zip_hi(x, y);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
XSIMD_IF_CONSTEXPR(detail::is_select(bsize, Indices...))
|
|
652
|
+
{
|
|
653
|
+
return select(batch_bool_constant<T, A, (Indices < bsize)...>(), x, y);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
#if defined(__has_builtin) && !defined(XSIMD_WITH_EMULATED)
|
|
657
|
+
#if __has_builtin(__builtin_shufflevector)
|
|
658
|
+
#define builtin_shuffle __builtin_shufflevector
|
|
659
|
+
#endif
|
|
660
|
+
#endif
|
|
661
|
+
|
|
662
|
+
#if defined(builtin_shuffle)
|
|
663
|
+
typedef T vty __attribute__((__vector_size__(sizeof(batch<T, A>))));
|
|
664
|
+
return (typename batch<T, A>::register_type)builtin_shuffle((vty)x.data, (vty)y.data, Indices...);
|
|
665
|
+
|
|
666
|
+
// FIXME: my experiments show that GCC only correctly optimizes this builtin
|
|
667
|
+
// starting at GCC 13, where it already has __builtin_shuffle_vector
|
|
668
|
+
//
|
|
669
|
+
// #elif __has_builtin(__builtin_shuffle) || GCC >= 6
|
|
670
|
+
// typedef ITy integer_vector_type __attribute__((vector_size(sizeof(batch<ITy, A>))));
|
|
671
|
+
// return __builtin_shuffle(x.data, y.data, integer_vector_type{Indices...});
|
|
672
|
+
#else
|
|
673
|
+
// Use a common_pattern. It is suboptimal but clang optimizes this
|
|
674
|
+
// pretty well.
|
|
675
|
+
batch<T, A> x_lane = swizzle(x, batch_constant<ITy, A, ((Indices >= bsize) ? (Indices - bsize) : Indices)...>());
|
|
676
|
+
batch<T, A> y_lane = swizzle(y, batch_constant<ITy, A, ((Indices >= bsize) ? (Indices - bsize) : Indices)...>());
|
|
677
|
+
batch_bool_constant<T, A, (Indices < bsize)...> select_x_lane;
|
|
678
|
+
return select(select_x_lane, x_lane, y_lane);
|
|
679
|
+
#endif
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// store
|
|
683
|
+
template <class A, class T>
|
|
684
|
+
XSIMD_INLINE void store(batch_bool<T, A> const& self, bool* mem, requires_arch<common>) noexcept
|
|
685
|
+
{
|
|
686
|
+
using batch_type = batch<T, A>;
|
|
687
|
+
constexpr auto size = batch_bool<T, A>::size;
|
|
688
|
+
alignas(A::alignment()) T buffer[size];
|
|
689
|
+
kernel::store_aligned<A>(&buffer[0], batch_type(self), A {});
|
|
690
|
+
for (std::size_t i = 0; i < size; ++i)
|
|
691
|
+
mem[i] = bool(buffer[i]);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
template <class A, class T>
|
|
695
|
+
XSIMD_INLINE void store_stream(batch_bool<T, A> const& self, bool* mem, requires_arch<common>) noexcept
|
|
696
|
+
{
|
|
697
|
+
store(self, mem, A {});
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// store_aligned
|
|
701
|
+
template <class A, class T_in, class T_out>
|
|
702
|
+
XSIMD_INLINE void store_aligned(T_out* mem, batch<T_in, A> const& self, requires_arch<common>) noexcept
|
|
703
|
+
{
|
|
704
|
+
static_assert(!std::is_same<T_in, T_out>::value, "there should be a direct store for this type combination");
|
|
705
|
+
alignas(A::alignment()) T_in buffer[batch<T_in, A>::size];
|
|
706
|
+
store_aligned(&buffer[0], self);
|
|
707
|
+
std::copy(std::begin(buffer), std::end(buffer), mem);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// store_unaligned
|
|
711
|
+
template <class A, class T_in, class T_out>
|
|
712
|
+
XSIMD_INLINE void store_unaligned(T_out* mem, batch<T_in, A> const& self, requires_arch<common>) noexcept
|
|
713
|
+
{
|
|
714
|
+
static_assert(!std::is_same<T_in, T_out>::value, "there should be a direct store for this type combination");
|
|
715
|
+
return store_aligned<A>(mem, self, common {});
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
template <class A, class T_in, class T_out>
|
|
719
|
+
XSIMD_INLINE void store_stream(T_out* mem, batch<T_in, A> const& self, requires_arch<common>) noexcept
|
|
720
|
+
{
|
|
721
|
+
store_aligned<A>(mem, self, A {});
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// swizzle
|
|
725
|
+
template <class A, class T, class ITy, ITy... Vs>
|
|
726
|
+
XSIMD_INLINE batch<std::complex<T>, A> swizzle(batch<std::complex<T>, A> const& self, batch_constant<ITy, A, Vs...> mask, requires_arch<common>) noexcept
|
|
727
|
+
{
|
|
728
|
+
return { swizzle(self.real(), mask), swizzle(self.imag(), mask) };
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
template <class A, class T, class ITy>
|
|
732
|
+
XSIMD_INLINE batch<T, A> swizzle(batch<T, A> const& self, batch<ITy, A> mask, requires_arch<common>) noexcept
|
|
733
|
+
{
|
|
734
|
+
constexpr size_t size = batch<T, A>::size;
|
|
735
|
+
alignas(A::alignment()) T self_buffer[size];
|
|
736
|
+
store_aligned(&self_buffer[0], self);
|
|
737
|
+
|
|
738
|
+
alignas(A::alignment()) ITy mask_buffer[size];
|
|
739
|
+
store_aligned(&mask_buffer[0], mask);
|
|
740
|
+
|
|
741
|
+
alignas(A::alignment()) T out_buffer[size];
|
|
742
|
+
for (size_t i = 0; i < size; ++i)
|
|
743
|
+
out_buffer[i] = self_buffer[mask_buffer[i]];
|
|
744
|
+
return batch<T, A>::load_aligned(out_buffer);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
template <class A, class T, class ITy, ITy... Is>
|
|
748
|
+
XSIMD_INLINE batch<T, A> swizzle(batch<T, A> const& self, batch_constant<ITy, A, Is...>, requires_arch<common>) noexcept
|
|
749
|
+
{
|
|
750
|
+
constexpr size_t size = batch<T, A>::size;
|
|
751
|
+
alignas(A::alignment()) T self_buffer[size];
|
|
752
|
+
store_aligned(&self_buffer[0], self);
|
|
753
|
+
return { self_buffer[Is]... };
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
template <class A, class T, class ITy>
|
|
757
|
+
XSIMD_INLINE batch<std::complex<T>, A> swizzle(batch<std::complex<T>, A> const& self, batch<ITy, A> mask, requires_arch<common>) noexcept
|
|
758
|
+
{
|
|
759
|
+
return { swizzle(self.real(), mask), swizzle(self.imag(), mask) };
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// load_complex_aligned
|
|
763
|
+
namespace detail
|
|
764
|
+
{
|
|
765
|
+
template <class A, class T>
|
|
766
|
+
XSIMD_INLINE batch<std::complex<T>, A> load_complex(batch<T, A> const& /*hi*/, batch<T, A> const& /*lo*/, requires_arch<common>) noexcept
|
|
767
|
+
{
|
|
768
|
+
static_assert(std::is_same<T, void>::value, "load_complex not implemented for the required architecture");
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
template <class A, class T>
|
|
772
|
+
XSIMD_INLINE batch<T, A> complex_high(batch<std::complex<T>, A> const& /*src*/, requires_arch<common>) noexcept
|
|
773
|
+
{
|
|
774
|
+
static_assert(std::is_same<T, void>::value, "complex_high not implemented for the required architecture");
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
template <class A, class T>
|
|
778
|
+
XSIMD_INLINE batch<T, A> complex_low(batch<std::complex<T>, A> const& /*src*/, requires_arch<common>) noexcept
|
|
779
|
+
{
|
|
780
|
+
static_assert(std::is_same<T, void>::value, "complex_low not implemented for the required architecture");
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
template <class A, class T_out, class T_in>
|
|
785
|
+
XSIMD_INLINE batch<std::complex<T_out>, A> load_complex_aligned(std::complex<T_in> const* mem, convert<std::complex<T_out>>, requires_arch<common>) noexcept
|
|
786
|
+
{
|
|
787
|
+
using real_batch = batch<T_out, A>;
|
|
788
|
+
T_in const* buffer = reinterpret_cast<T_in const*>(mem);
|
|
789
|
+
real_batch hi = real_batch::load_aligned(buffer),
|
|
790
|
+
lo = real_batch::load_aligned(buffer + real_batch::size);
|
|
791
|
+
return detail::load_complex(hi, lo, A {});
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// load_complex_unaligned
|
|
795
|
+
template <class A, class T_out, class T_in>
|
|
796
|
+
XSIMD_INLINE batch<std::complex<T_out>, A> load_complex_unaligned(std::complex<T_in> const* mem, convert<std::complex<T_out>>, requires_arch<common>) noexcept
|
|
797
|
+
{
|
|
798
|
+
using real_batch = batch<T_out, A>;
|
|
799
|
+
T_in const* buffer = reinterpret_cast<T_in const*>(mem);
|
|
800
|
+
real_batch hi = real_batch::load_unaligned(buffer),
|
|
801
|
+
lo = real_batch::load_unaligned(buffer + real_batch::size);
|
|
802
|
+
return detail::load_complex(hi, lo, A {});
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
template <class A, class T_out, class T_in>
|
|
806
|
+
XSIMD_INLINE batch<std::complex<T_out>, A> load_complex_stream(std::complex<T_in> const* mem, convert<std::complex<T_out>>, requires_arch<common>) noexcept
|
|
807
|
+
{
|
|
808
|
+
return load_complex_aligned<A>(mem, kernel::convert<std::complex<T_out>> {}, A {});
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// store_complex_aligned
|
|
812
|
+
template <class A, class T_out, class T_in>
|
|
813
|
+
XSIMD_INLINE void store_complex_aligned(std::complex<T_out>* dst, batch<std::complex<T_in>, A> const& src, requires_arch<common>) noexcept
|
|
814
|
+
{
|
|
815
|
+
using real_batch = batch<T_in, A>;
|
|
816
|
+
real_batch hi = detail::complex_high(src, A {});
|
|
817
|
+
real_batch lo = detail::complex_low(src, A {});
|
|
818
|
+
T_out* buffer = reinterpret_cast<T_out*>(dst);
|
|
819
|
+
lo.store_aligned(buffer);
|
|
820
|
+
hi.store_aligned(buffer + real_batch::size);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// store_complex_unaligned
|
|
824
|
+
template <class A, class T_out, class T_in>
|
|
825
|
+
XSIMD_INLINE void store_complex_unaligned(std::complex<T_out>* dst, batch<std::complex<T_in>, A> const& src, requires_arch<common>) noexcept
|
|
826
|
+
{
|
|
827
|
+
using real_batch = batch<T_in, A>;
|
|
828
|
+
real_batch hi = detail::complex_high(src, A {});
|
|
829
|
+
real_batch lo = detail::complex_low(src, A {});
|
|
830
|
+
T_out* buffer = reinterpret_cast<T_out*>(dst);
|
|
831
|
+
lo.store_unaligned(buffer);
|
|
832
|
+
hi.store_unaligned(buffer + real_batch::size);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
template <class A, class T_out, class T_in>
|
|
836
|
+
XSIMD_INLINE void store_complex_stream(std::complex<T_out>* dst, batch<std::complex<T_in>, A> const& src, requires_arch<common>) noexcept
|
|
837
|
+
{
|
|
838
|
+
store_complex_aligned<A>(dst, src, A {});
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// transpose
|
|
842
|
+
template <class A, class T>
|
|
843
|
+
XSIMD_INLINE void transpose(batch<T, A>* matrix_begin, batch<T, A>* matrix_end, requires_arch<common>) noexcept
|
|
844
|
+
{
|
|
845
|
+
assert((matrix_end - matrix_begin == batch<T, A>::size) && "correctly sized matrix");
|
|
846
|
+
(void)matrix_end;
|
|
847
|
+
alignas(A::alignment()) T scratch_buffer[batch<T, A>::size * batch<T, A>::size];
|
|
848
|
+
for (size_t i = 0; i < batch<T, A>::size; ++i)
|
|
849
|
+
{
|
|
850
|
+
matrix_begin[i].store_aligned(&scratch_buffer[i * batch<T, A>::size]);
|
|
851
|
+
}
|
|
852
|
+
// FIXME: this is super naive we can probably do better.
|
|
853
|
+
for (size_t i = 0; i < batch<T, A>::size; ++i)
|
|
854
|
+
{
|
|
855
|
+
for (size_t j = 0; j < i; ++j)
|
|
856
|
+
{
|
|
857
|
+
std::swap(scratch_buffer[i * batch<T, A>::size + j],
|
|
858
|
+
scratch_buffer[j * batch<T, A>::size + i]);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
for (size_t i = 0; i < batch<T, A>::size; ++i)
|
|
862
|
+
{
|
|
863
|
+
matrix_begin[i] = batch<T, A>::load_aligned(&scratch_buffer[i * batch<T, A>::size]);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// transpose
|
|
868
|
+
template <class A, class = std::enable_if_t<batch<int16_t, A>::size == 8>>
|
|
869
|
+
XSIMD_INLINE void transpose(batch<int16_t, A>* matrix_begin, batch<int16_t, A>* matrix_end, requires_arch<common>) noexcept
|
|
870
|
+
{
|
|
871
|
+
assert((matrix_end - matrix_begin == batch<int16_t, A>::size) && "correctly sized matrix");
|
|
872
|
+
(void)matrix_end;
|
|
873
|
+
auto l0 = zip_lo(matrix_begin[0], matrix_begin[1]);
|
|
874
|
+
auto l1 = zip_lo(matrix_begin[2], matrix_begin[3]);
|
|
875
|
+
auto l2 = zip_lo(matrix_begin[4], matrix_begin[5]);
|
|
876
|
+
auto l3 = zip_lo(matrix_begin[6], matrix_begin[7]);
|
|
877
|
+
|
|
878
|
+
auto l4 = zip_lo(bit_cast<batch<int32_t, A>>(l0), bit_cast<batch<int32_t, A>>(l1));
|
|
879
|
+
auto l5 = zip_lo(bit_cast<batch<int32_t, A>>(l2), bit_cast<batch<int32_t, A>>(l3));
|
|
880
|
+
|
|
881
|
+
auto l6 = zip_hi(bit_cast<batch<int32_t, A>>(l0), bit_cast<batch<int32_t, A>>(l1));
|
|
882
|
+
auto l7 = zip_hi(bit_cast<batch<int32_t, A>>(l2), bit_cast<batch<int32_t, A>>(l3));
|
|
883
|
+
|
|
884
|
+
auto h0 = zip_hi(matrix_begin[0], matrix_begin[1]);
|
|
885
|
+
auto h1 = zip_hi(matrix_begin[2], matrix_begin[3]);
|
|
886
|
+
auto h2 = zip_hi(matrix_begin[4], matrix_begin[5]);
|
|
887
|
+
auto h3 = zip_hi(matrix_begin[6], matrix_begin[7]);
|
|
888
|
+
|
|
889
|
+
auto h4 = zip_lo(bit_cast<batch<int32_t, A>>(h0), bit_cast<batch<int32_t, A>>(h1));
|
|
890
|
+
auto h5 = zip_lo(bit_cast<batch<int32_t, A>>(h2), bit_cast<batch<int32_t, A>>(h3));
|
|
891
|
+
|
|
892
|
+
auto h6 = zip_hi(bit_cast<batch<int32_t, A>>(h0), bit_cast<batch<int32_t, A>>(h1));
|
|
893
|
+
auto h7 = zip_hi(bit_cast<batch<int32_t, A>>(h2), bit_cast<batch<int32_t, A>>(h3));
|
|
894
|
+
|
|
895
|
+
matrix_begin[0] = bit_cast<batch<int16_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(l4), bit_cast<batch<int64_t, A>>(l5)));
|
|
896
|
+
matrix_begin[1] = bit_cast<batch<int16_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(l4), bit_cast<batch<int64_t, A>>(l5)));
|
|
897
|
+
matrix_begin[2] = bit_cast<batch<int16_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(l6), bit_cast<batch<int64_t, A>>(l7)));
|
|
898
|
+
matrix_begin[3] = bit_cast<batch<int16_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(l6), bit_cast<batch<int64_t, A>>(l7)));
|
|
899
|
+
|
|
900
|
+
matrix_begin[4] = bit_cast<batch<int16_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(h4), bit_cast<batch<int64_t, A>>(h5)));
|
|
901
|
+
matrix_begin[5] = bit_cast<batch<int16_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(h4), bit_cast<batch<int64_t, A>>(h5)));
|
|
902
|
+
matrix_begin[6] = bit_cast<batch<int16_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(h6), bit_cast<batch<int64_t, A>>(h7)));
|
|
903
|
+
matrix_begin[7] = bit_cast<batch<int16_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(h6), bit_cast<batch<int64_t, A>>(h7)));
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
template <class A>
|
|
907
|
+
XSIMD_INLINE void transpose(batch<uint16_t, A>* matrix_begin, batch<uint16_t, A>* matrix_end, requires_arch<common>) noexcept
|
|
908
|
+
{
|
|
909
|
+
transpose(reinterpret_cast<batch<int16_t, A>*>(matrix_begin), reinterpret_cast<batch<int16_t, A>*>(matrix_end), A {});
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
template <class A, class = std::enable_if_t<batch<int8_t, A>::size == 16>>
|
|
913
|
+
XSIMD_INLINE void transpose(batch<int8_t, A>* matrix_begin, batch<int8_t, A>* matrix_end, requires_arch<common>) noexcept
|
|
914
|
+
{
|
|
915
|
+
assert((matrix_end - matrix_begin == batch<int8_t, A>::size) && "correctly sized matrix");
|
|
916
|
+
(void)matrix_end;
|
|
917
|
+
auto l0 = zip_lo(matrix_begin[0], matrix_begin[1]);
|
|
918
|
+
auto l1 = zip_lo(matrix_begin[2], matrix_begin[3]);
|
|
919
|
+
auto l2 = zip_lo(matrix_begin[4], matrix_begin[5]);
|
|
920
|
+
auto l3 = zip_lo(matrix_begin[6], matrix_begin[7]);
|
|
921
|
+
auto l4 = zip_lo(matrix_begin[8], matrix_begin[9]);
|
|
922
|
+
auto l5 = zip_lo(matrix_begin[10], matrix_begin[11]);
|
|
923
|
+
auto l6 = zip_lo(matrix_begin[12], matrix_begin[13]);
|
|
924
|
+
auto l7 = zip_lo(matrix_begin[14], matrix_begin[15]);
|
|
925
|
+
|
|
926
|
+
auto h0 = zip_hi(matrix_begin[0], matrix_begin[1]);
|
|
927
|
+
auto h1 = zip_hi(matrix_begin[2], matrix_begin[3]);
|
|
928
|
+
auto h2 = zip_hi(matrix_begin[4], matrix_begin[5]);
|
|
929
|
+
auto h3 = zip_hi(matrix_begin[6], matrix_begin[7]);
|
|
930
|
+
auto h4 = zip_hi(matrix_begin[8], matrix_begin[9]);
|
|
931
|
+
auto h5 = zip_hi(matrix_begin[10], matrix_begin[11]);
|
|
932
|
+
auto h6 = zip_hi(matrix_begin[12], matrix_begin[13]);
|
|
933
|
+
auto h7 = zip_hi(matrix_begin[14], matrix_begin[15]);
|
|
934
|
+
|
|
935
|
+
auto L0 = zip_lo(bit_cast<batch<int16_t, A>>(l0), bit_cast<batch<int16_t, A>>(l1));
|
|
936
|
+
auto L1 = zip_lo(bit_cast<batch<int16_t, A>>(l2), bit_cast<batch<int16_t, A>>(l3));
|
|
937
|
+
auto L2 = zip_lo(bit_cast<batch<int16_t, A>>(l4), bit_cast<batch<int16_t, A>>(l5));
|
|
938
|
+
auto L3 = zip_lo(bit_cast<batch<int16_t, A>>(l6), bit_cast<batch<int16_t, A>>(l7));
|
|
939
|
+
|
|
940
|
+
auto m0 = zip_lo(bit_cast<batch<int32_t, A>>(L0), bit_cast<batch<int32_t, A>>(L1));
|
|
941
|
+
auto m1 = zip_lo(bit_cast<batch<int32_t, A>>(L2), bit_cast<batch<int32_t, A>>(L3));
|
|
942
|
+
auto m2 = zip_hi(bit_cast<batch<int32_t, A>>(L0), bit_cast<batch<int32_t, A>>(L1));
|
|
943
|
+
auto m3 = zip_hi(bit_cast<batch<int32_t, A>>(L2), bit_cast<batch<int32_t, A>>(L3));
|
|
944
|
+
|
|
945
|
+
matrix_begin[0] = bit_cast<batch<int8_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(m0), bit_cast<batch<int64_t, A>>(m1)));
|
|
946
|
+
matrix_begin[1] = bit_cast<batch<int8_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(m0), bit_cast<batch<int64_t, A>>(m1)));
|
|
947
|
+
matrix_begin[2] = bit_cast<batch<int8_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(m2), bit_cast<batch<int64_t, A>>(m3)));
|
|
948
|
+
matrix_begin[3] = bit_cast<batch<int8_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(m2), bit_cast<batch<int64_t, A>>(m3)));
|
|
949
|
+
|
|
950
|
+
auto L4 = zip_hi(bit_cast<batch<int16_t, A>>(l0), bit_cast<batch<int16_t, A>>(l1));
|
|
951
|
+
auto L5 = zip_hi(bit_cast<batch<int16_t, A>>(l2), bit_cast<batch<int16_t, A>>(l3));
|
|
952
|
+
auto L6 = zip_hi(bit_cast<batch<int16_t, A>>(l4), bit_cast<batch<int16_t, A>>(l5));
|
|
953
|
+
auto L7 = zip_hi(bit_cast<batch<int16_t, A>>(l6), bit_cast<batch<int16_t, A>>(l7));
|
|
954
|
+
|
|
955
|
+
auto m4 = zip_lo(bit_cast<batch<int32_t, A>>(L4), bit_cast<batch<int32_t, A>>(L5));
|
|
956
|
+
auto m5 = zip_lo(bit_cast<batch<int32_t, A>>(L6), bit_cast<batch<int32_t, A>>(L7));
|
|
957
|
+
auto m6 = zip_hi(bit_cast<batch<int32_t, A>>(L4), bit_cast<batch<int32_t, A>>(L5));
|
|
958
|
+
auto m7 = zip_hi(bit_cast<batch<int32_t, A>>(L6), bit_cast<batch<int32_t, A>>(L7));
|
|
959
|
+
|
|
960
|
+
matrix_begin[4] = bit_cast<batch<int8_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(m4), bit_cast<batch<int64_t, A>>(m5)));
|
|
961
|
+
matrix_begin[5] = bit_cast<batch<int8_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(m4), bit_cast<batch<int64_t, A>>(m5)));
|
|
962
|
+
matrix_begin[6] = bit_cast<batch<int8_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(m6), bit_cast<batch<int64_t, A>>(m7)));
|
|
963
|
+
matrix_begin[7] = bit_cast<batch<int8_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(m6), bit_cast<batch<int64_t, A>>(m7)));
|
|
964
|
+
|
|
965
|
+
auto H0 = zip_lo(bit_cast<batch<int16_t, A>>(h0), bit_cast<batch<int16_t, A>>(h1));
|
|
966
|
+
auto H1 = zip_lo(bit_cast<batch<int16_t, A>>(h2), bit_cast<batch<int16_t, A>>(h3));
|
|
967
|
+
auto H2 = zip_lo(bit_cast<batch<int16_t, A>>(h4), bit_cast<batch<int16_t, A>>(h5));
|
|
968
|
+
auto H3 = zip_lo(bit_cast<batch<int16_t, A>>(h6), bit_cast<batch<int16_t, A>>(h7));
|
|
969
|
+
|
|
970
|
+
auto M0 = zip_lo(bit_cast<batch<int32_t, A>>(H0), bit_cast<batch<int32_t, A>>(H1));
|
|
971
|
+
auto M1 = zip_lo(bit_cast<batch<int32_t, A>>(H2), bit_cast<batch<int32_t, A>>(H3));
|
|
972
|
+
auto M2 = zip_hi(bit_cast<batch<int32_t, A>>(H0), bit_cast<batch<int32_t, A>>(H1));
|
|
973
|
+
auto M3 = zip_hi(bit_cast<batch<int32_t, A>>(H2), bit_cast<batch<int32_t, A>>(H3));
|
|
974
|
+
|
|
975
|
+
matrix_begin[8] = bit_cast<batch<int8_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(M0), bit_cast<batch<int64_t, A>>(M1)));
|
|
976
|
+
matrix_begin[9] = bit_cast<batch<int8_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(M0), bit_cast<batch<int64_t, A>>(M1)));
|
|
977
|
+
matrix_begin[10] = bit_cast<batch<int8_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(M2), bit_cast<batch<int64_t, A>>(M3)));
|
|
978
|
+
matrix_begin[11] = bit_cast<batch<int8_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(M2), bit_cast<batch<int64_t, A>>(M3)));
|
|
979
|
+
|
|
980
|
+
auto H4 = zip_hi(bit_cast<batch<int16_t, A>>(h0), bit_cast<batch<int16_t, A>>(h1));
|
|
981
|
+
auto H5 = zip_hi(bit_cast<batch<int16_t, A>>(h2), bit_cast<batch<int16_t, A>>(h3));
|
|
982
|
+
auto H6 = zip_hi(bit_cast<batch<int16_t, A>>(h4), bit_cast<batch<int16_t, A>>(h5));
|
|
983
|
+
auto H7 = zip_hi(bit_cast<batch<int16_t, A>>(h6), bit_cast<batch<int16_t, A>>(h7));
|
|
984
|
+
|
|
985
|
+
auto M4 = zip_lo(bit_cast<batch<int32_t, A>>(H4), bit_cast<batch<int32_t, A>>(H5));
|
|
986
|
+
auto M5 = zip_lo(bit_cast<batch<int32_t, A>>(H6), bit_cast<batch<int32_t, A>>(H7));
|
|
987
|
+
auto M6 = zip_hi(bit_cast<batch<int32_t, A>>(H4), bit_cast<batch<int32_t, A>>(H5));
|
|
988
|
+
auto M7 = zip_hi(bit_cast<batch<int32_t, A>>(H6), bit_cast<batch<int32_t, A>>(H7));
|
|
989
|
+
|
|
990
|
+
matrix_begin[12] = bit_cast<batch<int8_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(M4), bit_cast<batch<int64_t, A>>(M5)));
|
|
991
|
+
matrix_begin[13] = bit_cast<batch<int8_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(M4), bit_cast<batch<int64_t, A>>(M5)));
|
|
992
|
+
matrix_begin[14] = bit_cast<batch<int8_t, A>>(zip_lo(bit_cast<batch<int64_t, A>>(M6), bit_cast<batch<int64_t, A>>(M7)));
|
|
993
|
+
matrix_begin[15] = bit_cast<batch<int8_t, A>>(zip_hi(bit_cast<batch<int64_t, A>>(M6), bit_cast<batch<int64_t, A>>(M7)));
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
template <class A>
|
|
997
|
+
XSIMD_INLINE void transpose(batch<uint8_t, A>* matrix_begin, batch<uint8_t, A>* matrix_end, requires_arch<common>) noexcept
|
|
998
|
+
{
|
|
999
|
+
transpose(reinterpret_cast<batch<int8_t, A>*>(matrix_begin), reinterpret_cast<batch<int8_t, A>*>(matrix_end), A {});
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
#endif
|