Skip to content

Commit

Permalink
Merge branch 'openvinotoolkit:master' into softmax_cross_entropy_loss…
Browse files Browse the repository at this point in the history
…_for_onnx_fe
  • Loading branch information
AJThePro99 authored Feb 8, 2025
2 parents 9a44591 + 06c3f20 commit 4242b3c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ONNX_FRONTEND_API NodeContext : public ov::frontend::NodeContext {

Output<ov::Node> get_input(int port_idx) const override;

const std::string& get_name() const override;

ov::Any get_attribute_as_any(const std::string& name) const override;

protected:
Expand Down
4 changes: 4 additions & 0 deletions src/frontends/onnx/frontend/src/node_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ ov::Output<ov::Node> ov::frontend::onnx::NodeContext::get_input(int port_idx) co
return m_inputs.at(port_idx);
}

const std::string& ov::frontend::onnx::NodeContext::get_name() const {
return m_context.get_name();
}

ov::Any ov::frontend::onnx::NodeContext::get_attribute_as_any(const std::string& name) const {
try {
return m_context.get_attribute_value<ov::Any>(name);
Expand Down
1 change: 1 addition & 0 deletions src/frontends/pytorch/src/op_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@ const std::unordered_map<std::string, CreatorFunction> get_supported_ops_fx() {
{"aten.hardtanh.default", op::translate_hardtanh},
{"aten.hardtanh_.default", op::inplace_op<op::translate_hardtanh>},
{"aten.index.Tensor", op::translate_index_fx},
{"aten._unsafe_index.Tensor", op::translate_index_fx},
{"aten.index_select.default", op::translate_index_select},
{"aten.isfinite.default", op::translate_1to1_match_1_inputs<opset10::IsFinite>},
{"aten.isinf.default", op::translate_1to1_match_1_inputs<opset10::IsInf>},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ void Transformations::MainSnippets(void) {
const auto is_bf16 = (in_type0 == ov::element::bf16 && in_type1 == ov::element::bf16) ||
((in_type0 == element::f32 && in_type1 == ov::element::f32 &&
config.inferencePrecision == ov::element::bf16));
const auto is_int8 = in_type0 == ov::element::i8;
const auto is_int8 = (in_type0 == element::i8 || in_type0 == element::u8) && (in_type1 == element::i8);
if (matmul->get_transpose_a()) {
return false;
}
Expand All @@ -1096,7 +1096,7 @@ void Transformations::MainSnippets(void) {
if (is_fp16) {
return dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core_amx_fp16);
}
return true;
return false;
};
auto is_unsupported_parallel_work_amount = [&](const std::shared_ptr<const ov::Node>& n,
const ov::PartialShape& shape) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,10 @@ void ov::npuw::JustInferRequest::unsafe_infer(std::size_t real_idx) {
// Collect spatial inputs for this offset
for (auto&& param : spatial.params) {
const auto& iport = comp_model_desc.compiled_model->inputs()[param.idx];
r->set_tensor(
iport,
ov::npuw::util::view(m_spatial_io[real_idx].inputs.at(param.idx), param.dim, offset, spatial.nway));
const auto& iview = ov::npuw::util::view(m_spatial_io[real_idx].inputs.at(param.idx),
param.dim, offset,
spatial.nway);
r->set_tensor(iport, iview);
} // for(params)

// Now set the spatial outputs
Expand Down
23 changes: 22 additions & 1 deletion src/plugins/intel_npu/src/plugin/npuw/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,32 @@ ov::SoPtr<ov::ITensor> ov::npuw::util::view(const ov::SoPtr<ov::ITensor>& src,
std::size_t offset,
std::size_t len) {
const auto& shape = src->get_shape();
NPUW_ASSERT(dim < shape.size());
View view_start = View(shape.size(), 0u);
View view_end = shape;
view_start[dim] = offset;
view_end[dim] = offset + len;
return ov::npuw::util::view(src, view_start, view_end);

auto ret_view = ov::npuw::util::view(src, view_start, view_end);

// Check if a tensor view can be faked as "continuous"
// FIXME: This trick should be removed after strided tensor
// checks are relaxed
if (std::all_of(shape.begin(), shape.begin() + dim, [](std::size_t d) { return d == 1u; })) {
// If all dimensions up to the sub-ranged dimension are 1s,
// This tensor can be faked as continuous
const auto type = src->get_element_type();
const auto view_shape = ret_view->get_shape();
ov::Strides fake_strides(shape.size());
fake_strides.back() = type.size();
std::transform(view_shape.crbegin(),
view_shape.crend() - 1,
fake_strides.rbegin(),
fake_strides.rbegin() + 1,
std::multiplies<size_t>());
return ov::get_tensor_impl(ov::Tensor(type, view_shape, ret_view->data(), fake_strides));
}
return ret_view;
}

template <typename InT>
Expand Down

0 comments on commit 4242b3c

Please sign in to comment.