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,89 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "types.h"
|
|
4
|
+
#include <third-party/xsimd/xsimd.hpp>
|
|
5
|
+
#include <algorithm>
|
|
6
|
+
#include <cstdint>
|
|
7
|
+
#include <iostream>
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <vector>
|
|
10
|
+
|
|
11
|
+
// Forward declarations
|
|
12
|
+
namespace phonemis::protophone {
|
|
13
|
+
template <typename T> class Tensor;
|
|
14
|
+
template <typename T> class TensorView;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
namespace phonemis::protophone::utils {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Calculates strides (from scratch) for given tensor shape.
|
|
21
|
+
* @param shape a tensor shape to calculate stride for
|
|
22
|
+
*/
|
|
23
|
+
inline std::vector<size_t> compute_strides(const std::vector<size_t>& shape) {
|
|
24
|
+
if (shape.empty()) return {};
|
|
25
|
+
|
|
26
|
+
std::vector<size_t> strides(shape.size());
|
|
27
|
+
|
|
28
|
+
size_t stride = 1;
|
|
29
|
+
for (int i = static_cast<int>(shape.size()) - 1; i >= 0; --i) {
|
|
30
|
+
strides[i] = stride;
|
|
31
|
+
stride *= shape[i];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return strides;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Reorganizes the data pointed to by a TensorView in-place to match canonical row-major strides.
|
|
39
|
+
* Generic implementation for any rank R that uses a temporary buffer.
|
|
40
|
+
*
|
|
41
|
+
* @tparam T The data type of the tensor elements.
|
|
42
|
+
* @param view The view to repack in-place.
|
|
43
|
+
*/
|
|
44
|
+
template <typename T>
|
|
45
|
+
inline void repack(TensorView<T>& view) {
|
|
46
|
+
const auto& shape = view.shape();
|
|
47
|
+
const auto& old_strides = view.strides();
|
|
48
|
+
const T* view_data = view.data() + view.offset();
|
|
49
|
+
|
|
50
|
+
std::vector<size_t> new_strides = compute_strides(shape);
|
|
51
|
+
size_t total_size = view.size();
|
|
52
|
+
|
|
53
|
+
std::vector<T, xsimd::default_allocator<T>> buffer(total_size);
|
|
54
|
+
|
|
55
|
+
for (size_t i = 0; i < total_size; ++i) {
|
|
56
|
+
size_t offset = 0;
|
|
57
|
+
size_t remaining = i;
|
|
58
|
+
for (size_t d = 0; d < shape.size(); ++d) {
|
|
59
|
+
size_t idx = remaining / new_strides[d];
|
|
60
|
+
remaining %= new_strides[d];
|
|
61
|
+
offset += idx * old_strides[d];
|
|
62
|
+
}
|
|
63
|
+
buffer[i] = view_data[offset];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
T* dest = view.data() + view.offset();
|
|
67
|
+
std::ranges::copy(buffer, dest);
|
|
68
|
+
|
|
69
|
+
// Update view metadata to reflect canonical strides
|
|
70
|
+
view.strides_ = std::move(new_strides);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Reorganizes the data of the input Tensor in-place to match canonical row-major strides.
|
|
75
|
+
* After this operation, the physical memory layout will be contiguous.
|
|
76
|
+
*
|
|
77
|
+
* @tparam T The data type of the tensor elements.
|
|
78
|
+
* @param tensor The tensor to be repacked in-place.
|
|
79
|
+
*/
|
|
80
|
+
template <typename T>
|
|
81
|
+
inline void repack(Tensor<T>& tensor) {
|
|
82
|
+
auto v = tensor.view();
|
|
83
|
+
repack<T>(v);
|
|
84
|
+
|
|
85
|
+
// Update tensor metadata to reflect canonical strides
|
|
86
|
+
tensor.strides_ = v.strides();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
} // namespace phonemis::protophone
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "meta.h"
|
|
4
|
+
#include "numeric.h"
|
|
5
|
+
#include "tensor_utils.h"
|
|
6
|
+
#include "types.h"
|
|
7
|
+
|
|
8
|
+
#include <algorithm>
|
|
9
|
+
#include <cstddef>
|
|
10
|
+
#include <numeric>
|
|
11
|
+
#include <stdexcept>
|
|
12
|
+
#include <variant>
|
|
13
|
+
#include <vector>
|
|
14
|
+
|
|
15
|
+
namespace phonemis::protophone {
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A non-owning view into a Tensor or a subset of its data.
|
|
19
|
+
* Facilitates slicing and zero-copy operations.
|
|
20
|
+
*/
|
|
21
|
+
template <typename T>
|
|
22
|
+
class TensorView {
|
|
23
|
+
public:
|
|
24
|
+
TensorView(T* data, std::vector<size_t> shape, std::vector<size_t> strides, size_t offset = 0)
|
|
25
|
+
: data_(data), shape_(std::move(shape)), strides_(std::move(strides)), offset_(offset) {}
|
|
26
|
+
|
|
27
|
+
// Simple accessors
|
|
28
|
+
T* data() { return data_; }
|
|
29
|
+
const T* data() const { return data_; }
|
|
30
|
+
const std::vector<size_t>& shape() const { return shape_; }
|
|
31
|
+
const std::vector<size_t>& strides() const { return strides_; }
|
|
32
|
+
size_t offset() const { return offset_; }
|
|
33
|
+
size_t size() const { return !shape_.empty() ? numeric::product(shape_) : 0; }
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns a reshaped view with the same data.
|
|
37
|
+
* @param new_shape The desired dimensions.
|
|
38
|
+
* @return A new TensorView with the updated shape.
|
|
39
|
+
* @throws std::invalid_argument if the new shape is incompatible with the total size.
|
|
40
|
+
*/
|
|
41
|
+
TensorView reshape(std::vector<size_t> new_shape) const {
|
|
42
|
+
if (numeric::product(shape_) != numeric::product(new_shape)) {
|
|
43
|
+
throw std::invalid_argument("New shape must have the same total size as the original.");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Logic for stride calculation in a reshaped view (assuming row-major linearized data)
|
|
47
|
+
std::vector<size_t> new_strides = utils::compute_strides(new_shape);
|
|
48
|
+
|
|
49
|
+
return TensorView(data_, std::move(new_shape), std::move(new_strides), offset_);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Returns a sliced view along multiple dimensions.
|
|
54
|
+
* Supports both single index and Range<size_t> slicing.
|
|
55
|
+
* @param args Pack of variants (size_t or Range<size_t>) for each dimension.
|
|
56
|
+
* A single size_t value corresponds to an index lookup (reduces dimensionality),
|
|
57
|
+
* while a Range<size_t> corresponds to range slicing (preserves dimensionality).
|
|
58
|
+
* @return A new TensorView representing the sub-region.
|
|
59
|
+
*/
|
|
60
|
+
template <typename... Args>
|
|
61
|
+
TensorView slice(Args... args) const {
|
|
62
|
+
// Aggregate all slices in iterable structure
|
|
63
|
+
std::vector<std::variant<size_t, Range<size_t>, All>> slices = {
|
|
64
|
+
meta::to_slice_variant(args)...
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
std::vector<size_t> new_shape;
|
|
68
|
+
std::vector<size_t> new_strides;
|
|
69
|
+
size_t new_offset = offset_;
|
|
70
|
+
|
|
71
|
+
for (size_t i = 0; i < slices.size(); ++i) {
|
|
72
|
+
if (std::holds_alternative<size_t>(slices[i])) {
|
|
73
|
+
size_t idx = std::get<size_t>(slices[i]);
|
|
74
|
+
new_offset += strides_[i] * idx;
|
|
75
|
+
} else if (std::holds_alternative<All>(slices[i])) {
|
|
76
|
+
new_shape.push_back(shape_[i]);
|
|
77
|
+
new_strides.push_back(strides_[i]);
|
|
78
|
+
} else {
|
|
79
|
+
Range<size_t> range = std::get<Range<size_t>>(slices[i]);
|
|
80
|
+
new_offset += strides_[i] * range.begin;
|
|
81
|
+
new_shape.push_back(range.end - range.begin);
|
|
82
|
+
new_strides.push_back(strides_[i]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Add remaining dimensions that weren't sliced
|
|
87
|
+
for (size_t i = slices.size(); i < shape_.size(); ++i) {
|
|
88
|
+
new_shape.push_back(shape_[i]);
|
|
89
|
+
new_strides.push_back(strides_[i]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return TensorView(data_, std::move(new_shape), std::move(new_strides), new_offset);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Returns a transposed view by swapping two dimensions.
|
|
97
|
+
* @param dim0 First dimension to swap.
|
|
98
|
+
* @param dim1 Second dimension to swap.
|
|
99
|
+
* @return A new TensorView with swapped shape and strides.
|
|
100
|
+
*/
|
|
101
|
+
TensorView transpose(size_t dim0 = 0, size_t dim1 = 1) const {
|
|
102
|
+
std::vector<size_t> new_shape = shape_;
|
|
103
|
+
std::vector<size_t> new_strides = strides_;
|
|
104
|
+
|
|
105
|
+
std::swap(new_shape[dim0], new_shape[dim1]);
|
|
106
|
+
std::swap(new_strides[dim0], new_strides[dim1]);
|
|
107
|
+
|
|
108
|
+
return TensorView(data_, std::move(new_shape), std::move(new_strides), offset_);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private:
|
|
112
|
+
// Friends declarations
|
|
113
|
+
template <typename U>
|
|
114
|
+
friend void utils::repack(TensorView<U>& view);
|
|
115
|
+
|
|
116
|
+
// Pointer to the original data buffer (non-owning)
|
|
117
|
+
T* data_;
|
|
118
|
+
|
|
119
|
+
// View metadata
|
|
120
|
+
std::vector<size_t> shape_;
|
|
121
|
+
std::vector<size_t> strides_;
|
|
122
|
+
size_t offset_;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
} // namespace phonemis::protophone
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
|
|
5
|
+
namespace phonemis::protophone {
|
|
6
|
+
|
|
7
|
+
// Forward declarations
|
|
8
|
+
template <typename T> class Tensor;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* General type definitions for custom neural inference.
|
|
12
|
+
*/
|
|
13
|
+
using Float = float;
|
|
14
|
+
using Long = int64_t;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Placeholder type for 'Entire range' semantic.
|
|
18
|
+
*/
|
|
19
|
+
struct All {};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Defines a pair of indices (i, j), which logicaly corresponds to a range
|
|
23
|
+
* i, i + 1, i + 2, ..., j - 2, j - 1.
|
|
24
|
+
*/
|
|
25
|
+
template <typename T>
|
|
26
|
+
struct Range {
|
|
27
|
+
T begin;
|
|
28
|
+
T end;
|
|
29
|
+
|
|
30
|
+
// Convenient alias for the global All type.
|
|
31
|
+
using ALL = All;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Defines weights of an affine transormation Wx + b.
|
|
36
|
+
*/
|
|
37
|
+
template <typename T>
|
|
38
|
+
struct Weights {
|
|
39
|
+
Tensor<T> weight;
|
|
40
|
+
Tensor<T> bias;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
} // namespace phonemis::protophone
|
|
@@ -33,8 +33,7 @@ inline bool is_alpha(const StringT& str) {
|
|
|
33
33
|
using std::isalpha;
|
|
34
34
|
using unicode::isalpha;
|
|
35
35
|
|
|
36
|
-
return std::all_of(str
|
|
37
|
-
[](auto c) -> bool { return isalpha(c); });
|
|
36
|
+
return std::ranges::all_of(str, [](auto c) -> bool { return isalpha(c); });
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
/**
|
|
@@ -47,8 +46,7 @@ inline bool is_all_lower(const StringT& str) {
|
|
|
47
46
|
using std::islower;
|
|
48
47
|
using unicode::islower;
|
|
49
48
|
|
|
50
|
-
return std::all_of(str
|
|
51
|
-
[](auto c) -> bool { return islower(c); });
|
|
49
|
+
return std::ranges::all_of(str, [](auto c) -> bool { return islower(c); });
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
/**
|
|
@@ -61,8 +59,7 @@ inline bool is_all_upper(const StringT& str) {
|
|
|
61
59
|
using std::isupper;
|
|
62
60
|
using unicode::isupper;
|
|
63
61
|
|
|
64
|
-
return std::all_of(str
|
|
65
|
-
[](auto c) -> bool { return isupper(c); });
|
|
62
|
+
return std::ranges::all_of(str, [](auto c) -> bool { return isupper(c); });
|
|
66
63
|
}
|
|
67
64
|
|
|
68
65
|
/**
|
|
@@ -91,6 +88,17 @@ inline bool starts_with(const StringT1& str, const PrefixT& prefix) {
|
|
|
91
88
|
str.substr(0, prefix_view.size()) == prefix_view;
|
|
92
89
|
}
|
|
93
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Checks if given string contains a given character.
|
|
93
|
+
* @param str The string to check.
|
|
94
|
+
* @param c The character to look for.
|
|
95
|
+
* @return True if c occurs in str.
|
|
96
|
+
*/
|
|
97
|
+
template <typename StringT, typename CharT>
|
|
98
|
+
inline bool contains(const StringT& str, CharT c) {
|
|
99
|
+
return std::ranges::find(str, c) != std::ranges::end(str);
|
|
100
|
+
}
|
|
101
|
+
|
|
94
102
|
|
|
95
103
|
// --------------------------------------------
|
|
96
104
|
// ----- Lower/Upper case transformations -----
|
|
@@ -135,8 +143,7 @@ inline void to_lower__(StringT& str) {
|
|
|
135
143
|
using std::tolower;
|
|
136
144
|
using unicode::tolower;
|
|
137
145
|
|
|
138
|
-
std::transform(str
|
|
139
|
-
[](auto c) { return tolower(c); });
|
|
146
|
+
std::ranges::transform(str, str.begin(), [](auto c) { return tolower(c); });
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
/**
|
|
@@ -148,8 +155,7 @@ inline void to_upper__(StringT& str) {
|
|
|
148
155
|
using std::toupper;
|
|
149
156
|
using unicode::toupper;
|
|
150
157
|
|
|
151
|
-
std::transform(str
|
|
152
|
-
[](auto c) { return toupper(c); });
|
|
158
|
+
std::ranges::transform(str, str.begin(), [](auto c) { return toupper(c); });
|
|
153
159
|
}
|
|
154
160
|
|
|
155
161
|
|
|
@@ -165,7 +171,7 @@ inline void to_upper__(StringT& str) {
|
|
|
165
171
|
*/
|
|
166
172
|
template <typename StringT, typename Pred>
|
|
167
173
|
inline void filter__(StringT& str, Pred pred) {
|
|
168
|
-
str.erase(std::remove_if(str
|
|
174
|
+
str.erase(std::ranges::remove_if(str, pred).begin(), str.end());
|
|
169
175
|
}
|
|
170
176
|
|
|
171
177
|
/**
|
|
@@ -176,7 +182,7 @@ inline void filter__(StringT& str, Pred pred) {
|
|
|
176
182
|
*/
|
|
177
183
|
template <typename StringT, typename CharT>
|
|
178
184
|
inline void replace__(StringT& str, CharT a, CharT b) {
|
|
179
|
-
std::replace(str
|
|
185
|
+
std::ranges::replace(str, a, b);
|
|
180
186
|
}
|
|
181
187
|
|
|
182
188
|
/**
|
|
@@ -186,7 +192,7 @@ inline void replace__(StringT& str, CharT a, CharT b) {
|
|
|
186
192
|
*/
|
|
187
193
|
template <typename StringT, typename CharT>
|
|
188
194
|
inline void remove__(StringT& str, CharT a) {
|
|
189
|
-
str.erase(std::remove(str
|
|
195
|
+
str.erase(std::ranges::remove(str, a).begin(), str.end());
|
|
190
196
|
}
|
|
191
197
|
|
|
192
198
|
/**
|
|
@@ -200,7 +206,7 @@ inline StringT strip(const StringT& str, std::optional<CharT> c = std::nullopt)
|
|
|
200
206
|
using std::isspace;
|
|
201
207
|
using unicode::isspace;
|
|
202
208
|
|
|
203
|
-
auto lbound = std::find_if(str.cbegin(), str.cend(),
|
|
209
|
+
auto lbound = std::find_if(str.cbegin(), str.cend(),
|
|
204
210
|
[&c](CharT a) -> bool { return c.has_value() ? a != c : !isspace(a); });
|
|
205
211
|
auto rbound = std::find_if(str.crbegin(), str.crend(),
|
|
206
212
|
[&c](CharT a) -> bool { return c.has_value() ? a != c : !isspace(a); });
|
|
@@ -16,6 +16,12 @@ constexpr inline bool is_ascii(char32_t c) {
|
|
|
16
16
|
return (c & ~0x7F) == 0;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
// A Latin letter, accented ones included
|
|
20
|
+
constexpr inline bool is_latin(char32_t c) {
|
|
21
|
+
return (c >= U'A' && c <= U'Z') || (c >= U'a' && c <= U'z') || (c >= U'À' && c <= U'Ö') || (c >= U'Ø' && c <= U'ö') ||
|
|
22
|
+
(c >= U'ø' && c <= U'ɏ');
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
constexpr inline bool isalpha(char32_t c) {
|
|
20
26
|
return (c < kLutSize) ? kUnicodeLut[c].is_alpha : false;
|
|
21
27
|
}
|
|
@@ -28,8 +34,16 @@ constexpr inline bool isalnum(char32_t c) {
|
|
|
28
34
|
return isalpha(c) || isdigit(c);
|
|
29
35
|
}
|
|
30
36
|
|
|
37
|
+
// A letter, a digit or "_": a word character of a regex (\w)
|
|
38
|
+
constexpr inline bool isword(char32_t c) {
|
|
39
|
+
return isalnum(c) || c == U'_';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Also the Unicode spaces: no-break, thin (14 h 20), ideographic, ...
|
|
31
43
|
constexpr inline bool isspace(char32_t c) {
|
|
32
|
-
return is_ascii(c) && std::isspace(static_cast<unsigned char>(c))
|
|
44
|
+
return (is_ascii(c) && std::isspace(static_cast<unsigned char>(c))) || c == U'\u0085' || c == U'\u00a0' ||
|
|
45
|
+
c == U'\u1680' || (c >= U'\u2000' && c <= U'\u200a') || c == U'\u2028' || c == U'\u2029' || c == U'\u202f' ||
|
|
46
|
+
c == U'\u205f' || c == U'\u3000';
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
constexpr inline bool islower(char32_t c) {
|
package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_arithmetic.hpp
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
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_ARITHMETIC_HPP
|
|
13
|
+
#define XSIMD_COMMON_ARITHMETIC_HPP
|
|
14
|
+
|
|
15
|
+
#include <complex>
|
|
16
|
+
#include <limits>
|
|
17
|
+
#include <type_traits>
|
|
18
|
+
|
|
19
|
+
#include "../../types/xsimd_batch_constant.hpp"
|
|
20
|
+
#include "./xsimd_common_details.hpp"
|
|
21
|
+
|
|
22
|
+
namespace xsimd
|
|
23
|
+
{
|
|
24
|
+
|
|
25
|
+
namespace kernel
|
|
26
|
+
{
|
|
27
|
+
|
|
28
|
+
using namespace types;
|
|
29
|
+
|
|
30
|
+
// bitwise_lshift
|
|
31
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
32
|
+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
33
|
+
{
|
|
34
|
+
return detail::apply([](T x, T y) noexcept
|
|
35
|
+
{ return x << y; },
|
|
36
|
+
self, other);
|
|
37
|
+
}
|
|
38
|
+
template <size_t shift, class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
39
|
+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
40
|
+
{
|
|
41
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
42
|
+
static_assert(shift < bits, "Shift must be less than the number of bits in T");
|
|
43
|
+
return bitwise_lshift(self, shift, A {});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// bitwise_rshift
|
|
47
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
48
|
+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
49
|
+
{
|
|
50
|
+
return detail::apply([](T x, T y) noexcept
|
|
51
|
+
{ return x >> y; },
|
|
52
|
+
self, other);
|
|
53
|
+
}
|
|
54
|
+
template <size_t shift, class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
55
|
+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
56
|
+
{
|
|
57
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
58
|
+
static_assert(shift < bits, "Shift must be less than the number of bits in T");
|
|
59
|
+
return bitwise_rshift(self, shift, A {});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// decr
|
|
63
|
+
template <class A, class T>
|
|
64
|
+
XSIMD_INLINE batch<T, A> decr(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
65
|
+
{
|
|
66
|
+
return self - T(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// decr_if
|
|
70
|
+
template <class A, class T, class Mask>
|
|
71
|
+
XSIMD_INLINE batch<T, A> decr_if(batch<T, A> const& self, Mask const& mask, requires_arch<common>) noexcept
|
|
72
|
+
{
|
|
73
|
+
return select(mask, decr(self), self);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// div
|
|
77
|
+
template <class A, class T, class = std::enable_if_t<std::is_integral<T>::value>>
|
|
78
|
+
XSIMD_INLINE batch<T, A> div(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
79
|
+
{
|
|
80
|
+
return detail::apply([](T x, T y) noexcept -> T
|
|
81
|
+
{ return x / y; },
|
|
82
|
+
self, other);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// fma
|
|
86
|
+
template <class A, class T>
|
|
87
|
+
XSIMD_INLINE batch<T, A> fma(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
88
|
+
{
|
|
89
|
+
return x * y + z;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
template <class A, class T>
|
|
93
|
+
XSIMD_INLINE batch<std::complex<T>, A> fma(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<common>) noexcept
|
|
94
|
+
{
|
|
95
|
+
auto res_r = fms(x.real(), y.real(), fms(x.imag(), y.imag(), z.real()));
|
|
96
|
+
auto res_i = fma(x.real(), y.imag(), fma(x.imag(), y.real(), z.imag()));
|
|
97
|
+
return { res_r, res_i };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// fms
|
|
101
|
+
template <class A, class T>
|
|
102
|
+
XSIMD_INLINE batch<T, A> fms(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
103
|
+
{
|
|
104
|
+
return x * y - z;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
template <class A, class T>
|
|
108
|
+
XSIMD_INLINE batch<std::complex<T>, A> fms(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<common>) noexcept
|
|
109
|
+
{
|
|
110
|
+
auto res_r = fms(x.real(), y.real(), fma(x.imag(), y.imag(), z.real()));
|
|
111
|
+
auto res_i = fma(x.real(), y.imag(), fms(x.imag(), y.real(), z.imag()));
|
|
112
|
+
return { res_r, res_i };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// fnma
|
|
116
|
+
template <class A, class T>
|
|
117
|
+
XSIMD_INLINE batch<T, A> fnma(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
118
|
+
{
|
|
119
|
+
return -x * y + z;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
template <class A, class T>
|
|
123
|
+
XSIMD_INLINE batch<std::complex<T>, A> fnma(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<common>) noexcept
|
|
124
|
+
{
|
|
125
|
+
auto res_r = -fms(x.real(), y.real(), fma(x.imag(), y.imag(), z.real()));
|
|
126
|
+
auto res_i = -fma(x.real(), y.imag(), fms(x.imag(), y.real(), z.imag()));
|
|
127
|
+
return { res_r, res_i };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// fnms
|
|
131
|
+
template <class A, class T>
|
|
132
|
+
XSIMD_INLINE batch<T, A> fnms(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
133
|
+
{
|
|
134
|
+
return -x * y - z;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
template <class A, class T>
|
|
138
|
+
XSIMD_INLINE batch<std::complex<T>, A> fnms(batch<std::complex<T>, A> const& x, batch<std::complex<T>, A> const& y, batch<std::complex<T>, A> const& z, requires_arch<common>) noexcept
|
|
139
|
+
{
|
|
140
|
+
auto res_r = -fms(x.real(), y.real(), fms(x.imag(), y.imag(), z.real()));
|
|
141
|
+
auto res_i = -fma(x.real(), y.imag(), fma(x.imag(), y.real(), z.imag()));
|
|
142
|
+
return { res_r, res_i };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// fmas
|
|
146
|
+
template <class A, class T>
|
|
147
|
+
XSIMD_INLINE batch<T, A> fmas(batch<T, A> const& x, batch<T, A> const& y, batch<T, A> const& z, requires_arch<common>) noexcept
|
|
148
|
+
{
|
|
149
|
+
struct even_lane
|
|
150
|
+
{
|
|
151
|
+
static constexpr bool get(unsigned const i, unsigned) noexcept { return (i & 1u) == 0; }
|
|
152
|
+
};
|
|
153
|
+
const auto mask = make_batch_bool_constant<T, even_lane, A>();
|
|
154
|
+
return fma(x, y, select(mask, neg(z), z));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// incr
|
|
158
|
+
template <class A, class T>
|
|
159
|
+
XSIMD_INLINE batch<T, A> incr(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
160
|
+
{
|
|
161
|
+
return self + T(1);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// incr_if
|
|
165
|
+
template <class A, class T, class Mask>
|
|
166
|
+
XSIMD_INLINE batch<T, A> incr_if(batch<T, A> const& self, Mask const& mask, requires_arch<common>) noexcept
|
|
167
|
+
{
|
|
168
|
+
return select(mask, incr(self), self);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// mul
|
|
172
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
173
|
+
XSIMD_INLINE batch<T, A> mul(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
174
|
+
{
|
|
175
|
+
return detail::apply([](T x, T y) noexcept -> T
|
|
176
|
+
{ return x * y; },
|
|
177
|
+
self, other);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// rotl
|
|
181
|
+
template <class A, class T, class STy>
|
|
182
|
+
XSIMD_INLINE batch<T, A> rotl(batch<T, A> const& self, STy other, requires_arch<common>) noexcept
|
|
183
|
+
{
|
|
184
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
185
|
+
return (self << other) | (self >> (bits - other));
|
|
186
|
+
}
|
|
187
|
+
template <size_t count, class A, class T>
|
|
188
|
+
XSIMD_INLINE batch<T, A> rotl(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
189
|
+
{
|
|
190
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
191
|
+
static_assert(count < bits, "Count amount must be less than the number of bits in T");
|
|
192
|
+
return bitwise_lshift<count>(self) | bitwise_rshift<bits - count>(self);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// rotr
|
|
196
|
+
template <class A, class T, class STy>
|
|
197
|
+
XSIMD_INLINE batch<T, A> rotr(batch<T, A> const& self, STy other, requires_arch<common>) noexcept
|
|
198
|
+
{
|
|
199
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
200
|
+
return (self >> other) | (self << (bits - other));
|
|
201
|
+
}
|
|
202
|
+
template <size_t count, class A, class T>
|
|
203
|
+
XSIMD_INLINE batch<T, A> rotr(batch<T, A> const& self, requires_arch<common>) noexcept
|
|
204
|
+
{
|
|
205
|
+
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
|
|
206
|
+
static_assert(count < bits, "Count must be less than the number of bits in T");
|
|
207
|
+
return bitwise_rshift<count>(self) | bitwise_lshift<bits - count>(self);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// sadd
|
|
211
|
+
template <class A>
|
|
212
|
+
XSIMD_INLINE batch<float, A> sadd(batch<float, A> const& self, batch<float, A> const& other, requires_arch<common>) noexcept
|
|
213
|
+
{
|
|
214
|
+
return add(self, other); // no saturated arithmetic on floating point numbers
|
|
215
|
+
}
|
|
216
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
217
|
+
XSIMD_INLINE batch<T, A> sadd(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
218
|
+
{
|
|
219
|
+
if (std::is_signed<T>::value)
|
|
220
|
+
{
|
|
221
|
+
auto self_pos_branch = min(std::numeric_limits<T>::max() - other, self);
|
|
222
|
+
auto self_neg_branch = max(std::numeric_limits<T>::min() - other, self);
|
|
223
|
+
return other + select(other >= 0, self_pos_branch, self_neg_branch);
|
|
224
|
+
}
|
|
225
|
+
else
|
|
226
|
+
{
|
|
227
|
+
const auto diffmax = std::numeric_limits<T>::max() - self;
|
|
228
|
+
const auto mindiff = min(diffmax, other);
|
|
229
|
+
return self + mindiff;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
template <class A>
|
|
233
|
+
XSIMD_INLINE batch<double, A> sadd(batch<double, A> const& self, batch<double, A> const& other, requires_arch<common>) noexcept
|
|
234
|
+
{
|
|
235
|
+
return add(self, other); // no saturated arithmetic on floating point numbers
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ssub
|
|
239
|
+
template <class A>
|
|
240
|
+
XSIMD_INLINE batch<float, A> ssub(batch<float, A> const& self, batch<float, A> const& other, requires_arch<common>) noexcept
|
|
241
|
+
{
|
|
242
|
+
return sub(self, other); // no saturated arithmetic on floating point numbers
|
|
243
|
+
}
|
|
244
|
+
template <class A, class T, class /*=std::enable_if_t<std::is_integral<T>::value>*/>
|
|
245
|
+
XSIMD_INLINE batch<T, A> ssub(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept
|
|
246
|
+
{
|
|
247
|
+
if (std::is_signed<T>::value)
|
|
248
|
+
{
|
|
249
|
+
return sadd(self, -other);
|
|
250
|
+
}
|
|
251
|
+
else
|
|
252
|
+
{
|
|
253
|
+
const auto diff = min(self, other);
|
|
254
|
+
return self - diff;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
template <class A>
|
|
258
|
+
XSIMD_INLINE batch<double, A> ssub(batch<double, A> const& self, batch<double, A> const& other, requires_arch<common>) noexcept
|
|
259
|
+
{
|
|
260
|
+
return sub(self, other); // no saturated arithmetic on floating point numbers
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
#endif
|