8000 Merge pull request #79 from howjmay/vmovn_s16 · plctlab/numpy@fa90b59 · GitHub
[go: up one dir, main page]

Skip to content

Commit fa90b59

Browse files
authored
Merge pull request numpy#79 from howjmay/vmovn_s16
feat: Add vmovn_s16
2 parents 78ad186 + abf15c3 commit fa90b59

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

neon2rvv.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,11 @@ FORCE_INLINE int8x8_t vget_low_s8(int8x16_t __a) {
21002100

21012101
// FORCE_INLINE uint32x4_t vcvtq_n_u32_f32(float32x4_t __a, const int __b);
21022102

2103-
// FORCE_INLINE int8x8_t vmovn_s16(int16x8_t __a);
2103+
FORCE_INLINE int8x8_t vmovn_s16(int16x8_t __a) {
2104+
uint8_t mask_arr[] = {85, 85};
2105+
vbool8_t mask = __riscv_vlm_v_b8(mask_arr, 16);
2106+
return __riscv_vcompress_vm_i8m1(__riscv_vreinterpret_v_i16m1_i8m1(__a), mask, 16);
2107+
}
21042108

21052109
// FORCE_INLINE int16x4_t vmovn_s32(int32x4_t __a);
21062110

tests/impl.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3219,7 +3219,16 @@ result_t test_vcvtq_n_f32_u32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { r
32193219

32203220
result_t test_vcvtq_n_u32_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
32213221

3222-
result_t test_vmovn_s16(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
3222+
result_t test_vmovn_s16(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
3223+
const int16_t *_a = (int16_t *)impl.test_cases_int_pointer1;
3224+
int8_t _c[8];
3225+
for (int i = 0; i < 8; i++) {
3226+
_c[i] = _a[i] & 0xff;
3227+
}
3228+
int16x8_t a = vld1q_s16(_a);
3229+
int8x8_t c = vmovn_s16(a);
3230+
return validate_int8(c, _c[0], _c[1], _c[2], _c[3], _c[4], _c[5], _c[6], _c[7]);
3231+
}
32233232

32243233
result_t test_vmovn_s32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
32253234

0 commit comments

Comments
 (0)
0