Add Mish for Snippets tokenization

This commit is contained in:
xuchen-intel 2024-06-07 07:39:42 +02:00
parent 798de0e108
commit b71be5e8de
4 changed files with 11 additions and 1 deletions

View File

@ -124,6 +124,7 @@ auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {
|| ov::is_type<ov::op::v0::Erf>(n)
|| ov::is_type<ov::op::v0::Exp>(n)
|| ov::is_type<ov::op::v1::LogicalNot>(n)
|| ov::is_type<ov::op::v4::Mish>(n)
|| ov::is_type<ov::op::v0::Negative>(n)
|| ov::is_type<ov::op::v0::Relu>(n)
|| ov::is_type<ov::op::v5::Round>(n)

View File

@ -101,6 +101,7 @@ CPUTargetMachine::CPUTargetMachine(dnnl::impl::cpu::aarch64::cpu_isa_t host_isa)
jitters[ov::op::v0::Exp::get_type_info_static()] = CREATE_CPU_EMITTER(jit_exp_emitter);
jitters[ov::op::v0::Floor::get_type_info_static()] = CREATE_CPU_EMITTER(jit_floor_emitter);
jitters[ov::op::v4::HSwish::get_type_info_static()] = CREATE_CPU_EMITTER(jit_hswish_emitter);
jitters[ov::op::v4::Mish::get_type_info_static()] = CREATE_CPU_EMITTER(jit_mish_emitter);
jitters[ov::op::v0::Relu::get_type_info_static()] = CREATE_CPU_EMITTER(jit_relu_emitter);
jitters[ov::op::v0::Sigmoid::get_type_info_static()] = CREATE_CPU_EMITTER(jit_sigmoid_emitter);
jitters[ov::intel_cpu::SwishNode::get_type_info_static()] = CREATE_CPU_EMITTER(jit_swish_emitter);

View File

@ -955,6 +955,7 @@ void Transformations::MainSnippets(void) {
ov::is_type<ov::op::v4::HSwish>(n) ||
ov::is_type<ov::op::v1::Maximum>(n) ||
ov::is_type<ov::op::v1::Minimum>(n) ||
ov::is_type<ov::op::v4::Mish>(n) ||
ov::is_type<ov::op::v1::Mod>(n) ||
ov::is_type<ov::op::v1::Multiply>(n) ||
ov::is_type<ov::op::v0::Relu>(n) ||
@ -968,6 +969,10 @@ void Transformations::MainSnippets(void) {
return ov::is_type<const ov::op::v4::Swish>(n) && n->inputs().size() > 1 &&
!ov::is_type<const ov::op::v0::Constant>(n->get_input_node_shared_ptr(1));
};
// CPU Plugin does not support the following ops for x64
auto is_unsupported_by_x64 = [](const std::shared_ptr<const ov::Node> &n) {
return ov::is_type<const ov::op::v4::Mish>(n);
};
// todo: general tokenization flow is not currently supported for these operations.
// they can be tokenized only as a part of complex patterns
auto is_unsupported_by_common_tokenization = [](const std::shared_ptr<const ov::Node> &n) {
@ -980,7 +985,7 @@ void Transformations::MainSnippets(void) {
ov::is_type<const ov::op::v1::ReduceMax>(n) ||
ov::is_type<const ov::op::v1::ReduceSum>(n));
};
return !is_unsupported_swish(n) && !is_unsupported_by_common_tokenization(n);
return !is_unsupported_swish(n) && !is_unsupported_by_x64(n) && !is_unsupported_by_common_tokenization(n);
#endif
};

View File

@ -241,6 +241,9 @@ const std::map<utils::ActivationTypes, std::vector<std::vector<float>>>& activat
{Floor, {{}}},
{Relu, {{}}},
{HSwish, {{}}},
#if defined(OPENVINO_ARCH_ARM64)
{Mish, {{}}},
#endif
{Sigmoid, {{}}},
{Swish, {{0.1f}}},
{Tanh, {{}}},