Skip to content

Commit

Permalink
cpu: aarch64: fp16 postops: disable ACL post ops for fp16
Browse files Browse the repository at this point in the history
The oneDNN API specifies that post ops need to (always)
be executed in fp32, but ACL executes them in f16
(when running in fp16 mode) which caused a lot of
conv+relu benchdnn tests to fail.
  • Loading branch information
fadara01 authored and igorsafo committed Nov 23, 2022
1 parent 3eb3267 commit f7b7dc0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cpu/aarch64/acl_post_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ struct acl_post_ops_t {
status_t init(engine_t *engine, post_ops_t &post_ops,
const memory_desc_t &dst_md) {

// Disable ACL post ops when in f16 mode. This is because the oneDNN reference runs
// the post op in f32 and then casts down to f16 while ACL runs the post op in f16
// leading to a loss of accuracy compared to ref.
ACL_CHECK_SUPPORT(
post_ops.len() >= 1 && dst_md.data_type == data_type::f16,
"post ops cannot be executed in fp16");
CHECK(post_ops.set_default_formats(&dst_md));

// Reset properties derived from post_ops
Expand Down Expand Up @@ -128,6 +134,12 @@ struct acl_post_ops_t {
const memory_desc_t &dst_md,
arm_compute::ActivationLayerInfo &act_info_to_fuse) {

// Disable ACL post ops when in f16 mode. This is because the oneDNN reference runs
// the post op in f32 and then casts down to f16 while ACL runs the post op in f16
// leading to a loss of accuracy compared to ref.
ACL_CHECK_SUPPORT(
base_post_ops.len() >= 1 && dst_md.data_type == data_type::f16,
"post ops cannot be executed in fp16");
CHECK(base_post_ops.set_default_formats(&dst_md));

// If the first entry is eltwise, we fuse it
Expand Down

0 comments on commit f7b7dc0

Please sign in to comment.