Skip to content

Commit

Permalink
affine, add_const, mul_const
Browse files Browse the repository at this point in the history
  • Loading branch information
kali committed May 9, 2023
1 parent fc8518a commit c8fd757
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
26 changes: 24 additions & 2 deletions linalg/arm64/arm64simd/arm64simd_act_f32_32n.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,33 @@
.max:
b .unsupported
.add_const:
b .unsupported
ins v24.s[0], w3
add x5, x5, 4
dup v24.4s, v24.s[0]
fadd v0.4s, v0.4s, v24.4s
fadd v1.4s, v1.4s, v24.4s
fadd v2.4s, v2.4s, v24.4s
fadd v3.4s, v3.4s, v24.4s
fadd v4.4s, v4.4s, v24.4s
fadd v5.4s, v5.4s, v24.4s
fadd v6.4s, v6.4s, v24.4s
fadd v7.4s, v7.4s, v24.4s
b .inner_loop
.sub_const:
b .unsupported
.mul_const:
b .unsupported
ins v24.s[0], w3
add x5, x5, 4
dup v24.4s, v24.s[0]
fmul v0.4s, v0.4s, v24.4s
fmul v1.4s, v1.4s, v24.4s
fmul v2.4s, v2.4s, v24.4s
fmul v3.4s, v3.4s, v24.4s
fmul v4.4s, v4.4s, v24.4s
fmul v5.4s, v5.4s, v24.4s
fmul v6.4s, v6.4s, v24.4s
fmul v7.4s, v7.4s, v24.4s
b .inner_loop
.min_const:
b .unsupported

Expand Down
25 changes: 25 additions & 0 deletions linalg/src/frame/activations/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ macro_rules! act_tests {
}
}

#[test]
fn add_const_prop(alpha in any::<$ti>(), x in x_strat()) {
if $cond {
run_kernel_test::<$ti, $ker>(&x, &[AddConst(alpha)], |x| x + alpha);
}
}

#[test]
fn mul_const_prop(alpha in any::<$ti>(), x in x_strat()) {
if $cond {
run_kernel_test::<$ti, $ker>(&x, &[MulConst(alpha)], |x| x * alpha);
}
}

#[test]
fn max_const_prop(alpha in any::<$ti>(), x in x_strat()) {
if $cond {
Expand Down Expand Up @@ -97,6 +111,17 @@ macro_rules! act_tests {
);
}
}

#[test]
fn affine_prop(x in x_strat(), alpha in any::<$ti>(), beta in any::<$ti>()) {
if $cond {
run_kernel_test::<$ti, $ker>(
&x,
&$crate::frame::activations::definitions::affine(alpha, beta).ops,
|x| x * alpha + beta
);
}
}
}
/*
prop_act_e2e!($cond, $ti, $ker, affine(alpha, beta));
Expand Down

0 comments on commit c8fd757

Please sign in to comment.