Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ggml/src/ggml-spacemit/rvv_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4109,7 +4109,9 @@ void forward_scale_f32(ggml::spacemit::context & ctx, ggml_tensor * op) {
GGML_ASSERT(src0->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F32);

float scale;
float bias;
memcpy(&scale, op->op_params, sizeof(float));
memcpy(&bias, op->op_params + 1, sizeof(float));

const int64_t ith = ctx.ith;
const int64_t nth = ctx.nth;
Expand All @@ -4135,7 +4137,12 @@ void forward_scale_f32(ggml::spacemit::context & ctx, ggml_tensor * op) {
while (remaining > 0) {
const size_t vl = __riscv_vsetvl_e32m4(remaining);
vfloat32m4_t v = __riscv_vle32_v_f32m4(src_row, vl);
v = __riscv_vfmul_vf_f32m4(v, scale, vl);
if (bias == 0.0f) {
v = __riscv_vfmul_vf_f32m4(v, scale, vl);
} else {
const auto offset = __riscv_vfmv_v_f_f32m4(bias, vl);
v = __riscv_vfmacc_vf_f32m4(offset, scale, v, vl);
}
__riscv_vse32_v_f32m4(dst_row, v, vl);
src_row += vl;
dst_row += vl;
Expand Down
Loading