Skip to content

Commit

Permalink
cpu: x64: post-op injector: use post-op order as a key for injector i…
Browse files Browse the repository at this point in the history
…nstance
  • Loading branch information
dzarukin committed Nov 28, 2022
1 parent f7b7dc0 commit 02c2678
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/cpu/x64/injectors/jit_uni_postops_injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ jit_uni_postops_injector_t<isa, Vmm>::jit_uni_postops_injector_t(
bool is_binary = false;
bool is_eltwise = false;

for (const auto &post_op : post_ops.entry_) {
for (int i = 0; i < post_ops.len(); i++) {
const auto &post_op = post_ops.entry_[i];
if (post_op.is_eltwise()) {
is_eltwise = true;
alg_to_eltwise_injector_.emplace(post_op.eltwise.alg,
alg_to_eltwise_injector_.emplace(i,
jit_uni_eltwise_injector_f32<isa, Vmm>(host_,
post_op.eltwise, esp.save_state, esp.p_table,
esp.k_mask, esp.is_fwd, esp.use_dst,
Expand Down Expand Up @@ -133,10 +134,10 @@ void jit_uni_postops_injector_t<isa, Vmm>::compute_vector_range(
const binary_injector::rhs_arg_dynamic_params_t &rhs_arg_params) {

std::size_t rhs_arg_idx = 0;
for (const auto &post_op : post_ops_.entry_) {
for (int i = 0; i < post_ops_.len(); i++) {
const auto &post_op = post_ops_.entry_[i];
if (post_op.is_eltwise()) {
alg_to_eltwise_injector_.at(post_op.eltwise.alg)
.compute_vector_range(vmm_idxs);
alg_to_eltwise_injector_.at(i).compute_vector_range(vmm_idxs);
} else if (post_op.is_binary()) {
binary_injector_->compute_vector_range(
vmm_idxs, rhs_arg_idx, post_op, rhs_arg_params);
Expand Down
5 changes: 3 additions & 2 deletions src/cpu/x64/injectors/jit_uni_postops_injector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class jit_uni_postops_injector_t {
private:
post_ops_t post_ops_;
jit_generator *host_;
std::map<dnnl::impl::alg_kind_t, jit_uni_eltwise_injector_f32<isa, Vmm>>
// Key is a numerical order of a post-op in attributes.
std::map<int, jit_uni_eltwise_injector_f32<isa, Vmm>>
alg_to_eltwise_injector_;
std::unique_ptr<binary_injector::jit_uni_binary_injector_t<isa, Vmm>>
binary_injector_;
Expand Down Expand Up @@ -163,4 +164,4 @@ bool post_ops_ok(const post_ops_ok_args_t &args);
} // namespace impl
} // namespace dnnl

#endif
#endif

0 comments on commit 02c2678

Please # to comment.