Skip to content

Commit

Permalink
Revert "[CPU] Prohibit fc avx2_vnni_2 decompression for bf16 input (#…
Browse files Browse the repository at this point in the history
…23638)"

This reverts commit c3c409e.
  • Loading branch information
rkazants authored Mar 26, 2024
1 parent c3c409e commit 91e9908
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ static const MappingNotation dnnlFCMappingNotation{ARG_SRC, ARG_WEI, ARG_BIAS, A
using LayoutConfig = std::vector<LayoutType>;
static const LayoutConfig dnnlFCLayoutConfig{LayoutType::ncsp, LayoutType::ncsp, LayoutType::ncsp, LayoutType::ncsp};

template<dnnl::impl::cpu::x64::cpu_isa_t ISA>
struct Require {
bool operator()() {
return dnnl::impl::cpu::x64::mayiuse(ISA);
}
};

// clang-format off
static const TypeMapping dnnlFCTypeMapping {
// {src, wei, bia, dst} pt<src, wei, bias, dst>
Expand All @@ -61,10 +54,7 @@ static const TypeMapping dnnlFCTypeMapping {
{{_u8 | _i8, _i8, _any, _f16}, pt(bypass(), bypass(), just<f32>(), just<f32>())},
{{_u8 | _i8, _i8, _any, _u8 | _i8 | _i32 | _bf16 | _f32}, pt(bypass(), bypass(), use<3>(), bypass())},
// compresses int weights (@todo more strict requrements for output precision?)
{{_bf16, _u8 | _nf4 | _u4 | _i4, _any, _any}, pt(bypass(), bypass(), use<0>(), use<0>()),
Require<dnnl::impl::cpu::x64::avx512_core_bf16>()}, // Ticket 122347
{{_bf16, _u8 | _nf4 | _u4 | _i4, _any, _any}, pt(just<f32>(), bypass(), just<f32>(), just<f32>())},
{{_f32, _u8 | _nf4 | _u4 | _i4, _any, _any}, pt(bypass(), bypass(), use<0>(), use<0>())},
{{_f32 | _bf16, _u8 | _nf4 | _u4 | _i4, _any, _any}, pt(bypass(), bypass(), use<0>(), use<0>())},
// @todo should we fallback to FPXX instead of _f32?
{{_any, _any, _any, _any}, pt(just<f32>(), just<f32>(), just<f32>(), just<f32>())},
// @todo explicitly cover configuration limitations for oneDNN on ARM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ InOutTypes getTypeConfiguration(const MemoryDescArgs& descriptors, const TypeMap
});

for (const auto& entry : mapping) {
if (!entry.enabled())
continue;

const auto& pattern = entry.mask();
const auto& pattern = entry.first;
if (!match(pattern, types))
continue;

return entry.translate(types);
const auto& translator = entry.second;
return translator(types);
}

OPENVINO_THROW("Failed to create a type configuration for the provided memory descriptors");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <cassert>
#include <functional>
#include <utility>
#include <vector>

#include "nodes/executors/memory_arguments.hpp"
Expand Down Expand Up @@ -81,43 +82,9 @@ struct PortsTranslation {
// pros: should be more efficient and safe
// cons: more template instances (binary size) of the translation utility functions
using InOutTypes = std::vector<ov::element::Type>;
using TypeTranslationFunction = std::function<InOutTypes(const InOutTypes&)>;
using PortsConfigurationImpl = std::function<InOutTypes(const InOutTypes&)>;
using InOutTypeMask = std::vector<TypeMask>;

class TypeMappingEntry {
public:
using EnabledPredicate = std::function<bool(void)>;

TypeMappingEntry(InOutTypeMask mask,
TypeTranslationFunction translation,
EnabledPredicate enabled = {})
: m_mask(std::move(mask)),
m_translation(std::move(translation)),
m_enabled(std::move(enabled)) {}

const InOutTypeMask& mask() const {
return m_mask;
}

InOutTypes translate(const InOutTypes& types) const {
if (m_translation)
return m_translation(types);
return {};
}

bool enabled() const {
if (m_enabled)
return m_enabled();
return true;
}

private:
InOutTypeMask m_mask;
TypeTranslationFunction m_translation;
EnabledPredicate m_enabled;
};

using TypeMapping = std::vector<TypeMappingEntry>;
using TypeMapping = std::vector<std::pair<InOutTypeMask, PortsConfigurationImpl>>;
using MappingNotation = std::vector<int>;
using pt = PortsTranslation;

Expand Down

0 comments on commit 91e9908

Please sign in to comment.