MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / zip_f32x4

Method zip_f32x4

crates/tinywasm/src/interpreter/simd/mod.rs:92–104  ·  view source on GitHub ↗
(self, rhs: Self, mut op: impl FnMut(f32, f32) -> f32)

Source from the content-addressed store, hash-verified

90
91 #[inline]
92 fn zip_f32x4(self, rhs: Self, mut op: impl FnMut(f32, f32) -> f32) -> Self {
93 let a_bytes = self.0;
94 let b_bytes = rhs.0;
95 let mut out_bytes = [0u8; 16];
96
97 for ((a, b), dst) in a_bytes.chunks_exact(4).zip(b_bytes.chunks_exact(4)).zip(out_bytes.chunks_exact_mut(4)) {
98 let a_lane = f32::from_bits(u32::from_le_bytes([a[0], a[1], a[2], a[3]]));
99 let b_lane = f32::from_bits(u32::from_le_bytes([b[0], b[1], b[2], b[3]]));
100 dst.copy_from_slice(&op(a_lane, b_lane).to_bits().to_le_bytes());
101 }
102
103 Self(out_bytes)
104 }
105
106 #[inline]
107 fn map_f64x2(self, mut op: impl FnMut(f64) -> f64) -> Self {

Callers 2

f32x4_relaxed_maddMethod · 0.80
f32x4_relaxed_nmaddMethod · 0.80

Calls 2

to_le_bytesMethod · 0.80
copy_from_sliceMethod · 0.45

Tested by

no test coverage detected