-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat): add support for microsoft.range operator for ONNX frontend
Signed-off-by: 11happy <[email protected]>
- Loading branch information
Showing
4 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/frontends/onnx/frontend/src/op/com.microsoft/range.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2018-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "core/operator_set.hpp" | ||
#include "openvino/op/ops.hpp" | ||
#include "openvino/frontend/exception.hpp" | ||
|
||
using namespace ov::op; | ||
|
||
namespace ov { | ||
namespace frontend { | ||
namespace onnx { | ||
namespace com_microsoft { | ||
namespace opset_1 { | ||
ov::OutputVector range(const ov::frontend::onnx::Node& node) { | ||
auto nodes = node.get_ov_inputs(); | ||
FRONT_END_GENERAL_CHECK((nodes.size() == 2 || nodes.size() == 3), "Range takes 2 or 3 inputs. Provided " + std::to_string(nodes.size())); | ||
auto start = nodes.at(0); | ||
auto limit = nodes.at(1); | ||
auto step = nodes.size() == 3 ? nodes.at(2) : ov::op::v0::Constant::create(start.get_element_type(), ov::Shape{}, {1}); | ||
return {std::make_shared<ov::op::v4::Range>(start, limit, step,start.get_element_type())}; | ||
} | ||
ONNX_OP("Range", OPSET_SINCE(1), com_microsoft::opset_1::range, MICROSOFT_DOMAIN); | ||
} // namespace opset_1 | ||
} // namespace com_microsoft | ||
} // namespace onnx | ||
} // namespace frontend | ||
} // namespace ov |
59 changes: 59 additions & 0 deletions
59
src/frontends/onnx/tests/models/com.microsoft/range_with_delta.prototxt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
ir_version: 6 | ||
producer_name: "OpenVINO ONNX Frontend" | ||
graph { | ||
node { | ||
input: "start" | ||
input: "limit" | ||
input: "delta" | ||
output: "output" | ||
op_type: "Range" | ||
} | ||
name: "test_range_float_type_with_delta" | ||
input { | ||
name: "start" | ||
type { | ||
tensor_type { | ||
elem_type: 1 | ||
shape { | ||
} | ||
} | ||
} | ||
} | ||
input { | ||
name: "limit" | ||
type { | ||
tensor_type { | ||
elem_type: 1 | ||
shape { | ||
} | ||
} | ||
} | ||
} | ||
input { | ||
name: "delta" | ||
type { | ||
tensor_type { | ||
elem_type: 1 | ||
shape { | ||
} | ||
} | ||
} | ||
} | ||
output { | ||
name: "output" | ||
type { | ||
tensor_type { | ||
elem_type: 1 | ||
shape { | ||
dim { | ||
dim_value: 10 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
opset_import { | ||
version: 1 | ||
domain: "com.microsoft" | ||
} |
48 changes: 48 additions & 0 deletions
48
src/frontends/onnx/tests/models/com.microsoft/range_without_delta.prototxt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
ir_version: 6 | ||
producer_name: "OpenVINO ONNX Frontend" | ||
graph { | ||
node { | ||
input: "start" | ||
input: "limit" | ||
output: "output" | ||
op_type: "Range" | ||
} | ||
name: "test_range_float_type_without_delta" | ||
input { | ||
name: "start" | ||
type { | ||
tensor_type { | ||
elem_type: 1 | ||
shape { | ||
} | ||
} | ||
} | ||
} | ||
input { | ||
name: "limit" | ||
type { | ||
tensor_type { | ||
elem_type: 1 | ||
shape { | ||
} | ||
} | ||
} | ||
} | ||
output { | ||
name: "output" | ||
type { | ||
tensor_type { | ||
elem_type: 1 | ||
shape { | ||
dim { | ||
dim_value: 10 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
opset_import { | ||
version: 1 | ||
domain: "com.microsoft" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters