Skip to content

Commit

Permalink
CREATE_UNDEFINED_EMITTER simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
v-Golubev committed Jan 30, 2024
1 parent d469e55 commit 8f18c38
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 27 deletions.
7 changes: 0 additions & 7 deletions src/common/snippets/include/snippets/target_machine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ class TargetMachine {
*/
virtual size_t get_lanes() const = 0;

/**
* @brief reports supported precisions set for nodes which don't have emitters
* @param type node type for which the supported precisions set is requested
* @return set of supported precisions for the provided node type
*/
virtual std::set<ov::element::TypeVector> supported_precisions_for_emitterless_node(const ov::DiscreteTypeInfo& type) const;

/**
* @brief called by generator to all the emitter for a target machine
* @return a map by node's type info with callbacks to create an instance of emitter for corresponding operation type
Expand Down
4 changes: 0 additions & 4 deletions src/common/snippets/src/lowered/target_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#include "snippets/target_machine.hpp"

using namespace ov::snippets;
std::set<ov::element::TypeVector> TargetMachine::supported_precisions_for_emitterless_node(const ov::DiscreteTypeInfo& type) const {
OPENVINO_THROW("supported_precisions_for_emitterless_node for this class is not implemented");
}

std::function<std::shared_ptr<Emitter>(const lowered::ExpressionPtr&)> TargetMachine::get(const ov::DiscreteTypeInfo& type) const {
auto jitter = jitters.find(type);
if (jitter == jitters.end()) {
Expand Down
20 changes: 5 additions & 15 deletions src/plugins/intel_cpu/src/emitters/snippets/x64/cpu_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ static bool is_segfault_detector_emitter(const intel_cpu::jit_emitter *emitter)
} \
}

#define CREATE_UNDEFINED_EMITTER() { \
#define CREATE_UNDEFINED_EMITTER(supported_precisions) { \
[](const snippets::lowered::ExpressionPtr& expr) -> std::shared_ptr<snippets::Emitter> { \
return nullptr; \
}, \
[this](const std::shared_ptr<ov::Node>& n) -> std::set<std::vector<element::Type>> { \
return supported_precisions_for_emitterless_node(n->get_type_info()); \
[](const std::shared_ptr<ov::Node>& n) -> std::set<std::vector<element::Type>> { \
return supported_precisions; \
} \
}

Expand Down Expand Up @@ -213,8 +213,8 @@ intel_cpu::CPUTargetMachine::CPUTargetMachine(dnnl::impl::cpu::x64::cpu_isa_t ho
jitters[snippets::op::LoopEnd::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(intel_cpu::jit_loop_end_emitter);
jitters[intel_cpu::BrgemmCPU::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(intel_cpu::jit_brgemm_emitter);
jitters[intel_cpu::BrgemmCopyB::get_type_info_static()] = CREATE_SNIPPETS_EMITTER(intel_cpu::jit_brgemm_copy_b_emitter);
jitters[snippets::op::ReduceMax::get_type_info_static()] = CREATE_UNDEFINED_EMITTER();
jitters[snippets::op::ReduceSum::get_type_info_static()] = CREATE_UNDEFINED_EMITTER();
jitters[snippets::op::ReduceMax::get_type_info_static()] = CREATE_UNDEFINED_EMITTER({{ov::element::f32}});
jitters[snippets::op::ReduceSum::get_type_info_static()] = CREATE_UNDEFINED_EMITTER({{ov::element::f32}});

#ifdef SNIPPETS_DEBUG_CAPS
jitters[snippets::op::PerfCountBegin::get_type_info_static()] = CREATE_CPU_EMITTER(ov::intel_cpu::jit_perf_count_chrono_start_emitter);
Expand All @@ -241,16 +241,6 @@ bool intel_cpu::CPUTargetMachine::is_supported() const {
return dnnl::impl::cpu::x64::mayiuse(isa);
}

std::set<ov::element::TypeVector> intel_cpu::CPUTargetMachine::supported_precisions_for_emitterless_node(const ov::DiscreteTypeInfo& type) const {
static const std::map<ov::DiscreteTypeInfo, std::set<ov::element::TypeVector>> supported_precisions_map{
{snippets::op::ReduceMax::get_type_info_static(), {{ov::element::f32}}},
{snippets::op::ReduceSum::get_type_info_static(), {{ov::element::f32}}},
};
auto it = supported_precisions_map.find(type);
OPENVINO_ASSERT(it != supported_precisions_map.end(), "supported precisions set for node without emitter is not set. Type info: ", type);
return it->second;
}

snippets::CompiledSnippetPtr intel_cpu::CPUTargetMachine::get_snippet() {
if (h->create_kernel() != dnnl::impl::status::success) {
OPENVINO_THROW("Failed to create jit_kernel in get_snippet()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class CPUTargetMachine : public snippets::TargetMachine {
snippets::CompiledSnippetPtr get_snippet() override;
size_t get_lanes() const override;
dnnl::impl::cpu::x64::cpu_isa_t get_isa() const;
std::set<ov::element::TypeVector> supported_precisions_for_emitterless_node(const ov::DiscreteTypeInfo& type) const override;
#ifdef SNIPPETS_DEBUG_CAPS
SnippetsDebugCapsConfig debug_config;
#endif
Expand Down

0 comments on commit 8f18c38

Please sign in to comment.