Skip to content

Commit

Permalink
src: cpu: reorder: simple: use additional_buffer_size to compute offset
Browse files Browse the repository at this point in the history
  • Loading branch information
igorsafo committed Apr 26, 2022
1 parent ef1d9fa commit 8b960df
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/cpu/reorder/simple_reorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,9 @@ struct simple_reorder_impl<SIMPLE_REORDER_TEMPL_CALL,
= utils::one_of(tag_o, format_tag::dhwio, format_tag::dhwigo);

const auto &dims = input_d.dims();
const auto &pdims = input_d.padded_dims();

const dim_t G = w_groups ? dims[0] : 1;
const dim_t OC = dims[w_groups + 0];
const dim_t PADDED_OC = pdims[w_groups + 0];
const dim_t IC = dims[w_groups + 1];
const dim_t D = w_depth ? dims[w_groups + 2] : 1;
const dim_t H = w_height ? dims[w_groups + w_depth + 2] : 1;
Expand All @@ -202,8 +200,9 @@ struct simple_reorder_impl<SIMPLE_REORDER_TEMPL_CALL,
: 1.f;

size_t offset = output_d.size() - output_d.additional_buffer_size();
size_t zp_offset
= offset + (req_comp ? G * PADDED_OC * sizeof(int32_t) : 0);
size_t comp_size = output_d.additional_buffer_size(
memory_extra_flags::compensation_conv_s8s8);
size_t zp_offset = offset + (req_comp ? comp_size : 0);
int32_t *cp = req_comp ? reinterpret_cast<int32_t *>(output + offset)
: nullptr;
int32_t *zp = has_asymmetric_comp
Expand Down Expand Up @@ -429,8 +428,9 @@ struct simple_reorder_impl<SIMPLE_REORDER_TEMPL_CALL,
constexpr dim_t o_mult = 1;

size_t offset = output_d.size() - output_d.additional_buffer_size();
size_t zp_offset
= offset + (req_comp ? G * PADDED_OC * sizeof(int32_t) : 0);
size_t comp_size = output_d.additional_buffer_size(
memory_extra_flags::compensation_conv_s8s8);
size_t zp_offset = offset + (req_comp ? comp_size : 0);
int32_t *cp = req_comp ? reinterpret_cast<int32_t *>(output + offset)
: nullptr;
int32_t *zp = has_asymmetric_comp
Expand Down Expand Up @@ -907,7 +907,9 @@ struct simple_reorder_impl<SIMPLE_REORDER_TEMPL_CALL,

const auto w_d = order_keep ? output_d : input_d;
size_t offset = w_d.size() - w_d.additional_buffer_size();
size_t zp_offset = offset + (req_comp ? pdims[1] * sizeof(int32_t) : 0);
size_t comp_size = output_d.additional_buffer_size(
memory_extra_flags::compensation_conv_s8s8);
size_t zp_offset = offset + (req_comp ? comp_size : 0);
int32_t *cp = req_comp ? reinterpret_cast<int32_t *>(output + offset)
: nullptr;
int32_t *zp = has_asymmetric_comp
Expand Down Expand Up @@ -1054,7 +1056,9 @@ struct simple_reorder_impl<SIMPLE_REORDER_TEMPL_CALL,
};

size_t offset = output_d.size() - output_d.additional_buffer_size();
size_t zp_offset = offset + (req_comp ? Gp * OC * sizeof(int32_t) : 0);
size_t comp_size = output_d.additional_buffer_size(
memory_extra_flags::compensation_conv_s8s8);
size_t zp_offset = offset + (req_comp ? comp_size : 0);
int32_t *cp = req_comp ? reinterpret_cast<int32_t *>(output + offset)
: nullptr;
int32_t *zp = has_asymmetric_comp
Expand Down

0 comments on commit 8b960df

Please sign in to comment.