Skip to content

Commit

Permalink
NPUW: Use dynamic dispatch for AVX2 code
Browse files Browse the repository at this point in the history
  • Loading branch information
eshiryae committed Oct 14, 2024
1 parent 81e141c commit 1e6748b
Show file tree
Hide file tree
Showing 7 changed files with 1,671 additions and 1,584 deletions.
11 changes: 7 additions & 4 deletions src/plugins/intel_npu/src/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ target_include_directories(${TARGET_NAME}
$<TARGET_PROPERTY:LevelZero::NPUExt,INTERFACE_INCLUDE_DIRECTORIES>
)

if(ENABLE_AVX2)
ov_avx2_optimization_flags(avx2_flags)
target_compile_options(${TARGET_NAME} PRIVATE "${avx2_flags}")
endif()
cross_compiled_file(${TARGET_NAME}
ARCH AVX2 ANY
npuw/util_xarch.cpp
API npuw/util_xarch.hpp
NAME unpack unpack_scale unpack_scale_zp to_f16
NAMESPACE ov::npuw::util::XARCH
)

ov_add_api_validator_post_build_step(TARGET ${NPU_PLUGIN_TARGET})
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "openvino/runtime/make_tensor.hpp"
#include "plugin.hpp"
#include "util.hpp"
#include "util_xarch.hpp"
#include "weights_bank.hpp"

ov::npuw::JustInferRequest::JustInferRequest(const std::shared_ptr<ov::npuw::CompiledModel>& compiled_model)
Expand Down Expand Up @@ -617,18 +618,18 @@ void ov::npuw::JustInferRequest::unpack_closure(std::size_t idx, RqPtr request)

if (!comp_model_desc.scales.empty() && comp_model_desc.scales[cidx] && comp_model_desc.zerops[cidx]) {
// Unpacking this weight requires scaling with zero points...
ov::npuw::util::unpack(ov::get_tensor_impl(closure),
ov::get_tensor_impl(comp_model_desc.zerops[cidx]),
ov::get_tensor_impl(comp_model_desc.scales[cidx]),
clparam);
ov::npuw::util::XARCH::unpack_scale_zp(ov::get_tensor_impl(closure),
ov::get_tensor_impl(comp_model_desc.zerops[cidx]),
ov::get_tensor_impl(comp_model_desc.scales[cidx]),
clparam);
} else if (!comp_model_desc.scales.empty() && comp_model_desc.scales[cidx]) {
// Unpacking this weight requires scaling
ov::npuw::util::unpack(ov::get_tensor_impl(closure),
ov::npuw::util::XARCH::unpack_scale(ov::get_tensor_impl(closure),
ov::get_tensor_impl(comp_model_desc.scales[cidx]),
clparam);
} else {
// Unpacking this weight doesn't require scaling
ov::npuw::util::unpack(ov::get_tensor_impl(closure), clparam);
ov::npuw::util::XARCH::unpack(ov::get_tensor_impl(closure), clparam);
}
}
}
Expand Down
Loading

0 comments on commit 1e6748b

Please sign in to comment.