We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 623ab6e commit 463e3eeCopy full SHA for 463e3ee
include/gemmini_params.h
@@ -59,6 +59,12 @@ typedef uint32_t acc_scale_t_bits;
59
i % 2 == 0 ? i : next)); \
60
result; })
61
62
+// Rounding right shift equation: https://riscv.github.io/documents/riscv-v-spec/#_vector_fixed_point_rounding_mode_register_vxrm
63
+#define ROUNDING_RIGHT_SHIFT_BITS(x, shift) \
64
+((shift) > 0 ? (((x) >> (shift)) + \
65
+ (((shift) == 0 ? 0 : (((x) >> ((shift)-1)) & 1)) & \
66
+ ((((shift) <= 1 ? 0 : ((x) & ((1 << ((shift)-1)) - 1))) != 0) | (((x) >> (shift)) & 1)))) : ((x) << (-(shift))))
67
+
68
#define ACC_SCALE(x, scale) \
69
({float y = ROUND_NEAR_EVEN((x) * (scale)); y > INT8_MAX ? INT8_MAX : (y < INT8_MIN ? INT8_MIN : (acc_t)y);})
70
0 commit comments