//*****************************************************************************
#include "constant.hpp"
+#include "ngraph/log.hpp"
#include "ngraph/op/constant.hpp"
#include "onnx_import/core/tensor.hpp"
#include "onnx_import/default_opset.hpp"
inline std::shared_ptr<default_opset::Constant>
__make_ng_constant(const element::Type& type, const Tensor& tensor)
{
- return std::make_shared<default_opset::Constant>(
- type, tensor.get_shape(), tensor.get_data<T>());
+ std::shared_ptr<default_opset::Constant> constant{nullptr};
+ try
+ {
+ constant = std::make_shared<default_opset::Constant>(
+ type, tensor.get_shape(), tensor.get_data<T>());
+ }
+ catch (const ngraph::ngraph_error& exc)
+ {
+ NGRAPH_WARN << "Could not create an nGraph Constant for an ONNX "
+ "Constant node. Detailed error:\n"
+ << exc.what();
+ constant = std::make_shared<default_opset::Constant>(type, Shape{}, 0);
+ }
+
+ return constant;
}
template <Tensor::Type>
if (inputs.size() == 4) // sizes input is provided
{
+ attrs.shape_calculation_mode =
+ default_opset::Interpolate::ShapeCalcMode::sizes;
const auto& sizes = inputs.at(3);
const auto& sizes_shape = sizes.get_partial_shape();
data, sizes, scales, attrs)};
}
+ attrs.shape_calculation_mode =
+ default_opset::Interpolate::ShapeCalcMode::scales;
+
const auto& scales = inputs.at(2);
const auto& scales_shape = scales.get_partial_shape();
--- /dev/null
+ir_version: 7
+producer_name: "onnx-importer-test"
+graph {
+ node {
+ output: "empty_const"
+ op_type: "Constant"
+ attribute {
+ name: "value"
+ t {
+ dims: 0
+ data_type: 1
+ raw_data: ""
+ }
+ type: TENSOR
+ }
+ }
+ node {
+ output: "scales"
+ op_type: "Constant"
+ attribute {
+ name: "value"
+ t {
+ dims: 4
+ data_type: 1
+ float_data: 1.0
+ float_data: 1.0
+ float_data: 2.0
+ float_data: 4.0
+ }
+ type: TENSOR
+ }
+ }
+ node {
+ input: "X"
+ input: "empty_const"
+ input: "scales"
+ output: "Y"
+ op_type: "Resize"
+ attribute {
+ name: "coordinate_transformation_mode"
+ s: "asymmetric"
+ type: STRING
+ }
+ attribute {
+ name: "cubic_coeff_a"
+ f: -0.75
+ type: FLOAT
+ }
+ attribute {
+ name: "exclude_outside"
+ i: 0
+ type: INT
+ }
+ attribute {
+ name: "extrapolation_value"
+ f: 0
+ type: FLOAT
+ }
+ attribute {
+ name: "mode"
+ s: "linear"
+ type: STRING
+ }
+ attribute {
+ name: "nearest_mode"
+ s: "floor"
+ type: STRING
+ }
+ }
+ name: "test-model"
+ input {
+ name: "X"
+ type {
+ tensor_type {
+ elem_type: 1
+ shape {
+ dim {
+ dim_value: 1
+ }
+ dim {
+ dim_value: 2
+ }
+ dim {
+ dim_value: 2
+ }
+ dim {
+ dim_value: 2
+ }
+ }
+ }
+ }
+ }
+ output {
+ name: "Y"
+ type {
+ tensor_type {
+ elem_type: 1
+ shape {
+ dim {
+ dim_value: 1
+ }
+ dim {
+ dim_value: 2
+ }
+ dim {
+ dim_value: 4
+ }
+ dim {
+ dim_value: 8
+ }
+ }
+ }
+ }
+ }
+}
+opset_import {
+ domain: ""
+ version: 11
+}
test_case.run();
}
+NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_empty_constant_as_input)
+{
+ // this model contains a Constant node with an empty underlying tensor
+ // this node is connected to the "roi" input of the Resize op but this input should be
+ // ignored since the Resize coordinate_transformation_mode is set to asymmetric
+ const auto function = onnx_import::import_onnx_model(
+ file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_empty_constant_as_input.prototxt"));
+
+ auto test_case = test::TestCase<TestEngine>(function);
+ std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
+ test_case.add_input<float>(input_data);
+ test_case.add_expected_output<float>(
+ Shape{1, 2, 4, 8},
+ {1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 2.5f, 3.25f, 4.0f,
+ 4.75f, 5.5f, 5.5f, 5.5f, 5.5f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 8.0f,
+ 8.0f, 8.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 8.0f, 8.0f, 8.0f,
+
+ 6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 2.0f, 2.0f, 2.0f, 6.5f, 6.5f, 6.5f,
+ 6.5f, 6.5f, 6.5f, 6.5f, 6.5f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f,
+ 11.0f, 11.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f, 11.0f, 11.0f});
+
+ test_case.run();
+}
+
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_shape)
{
auto function =
onnx_model_gru_fwd_linear_before_reset
# Not implemented Interpolate-4:
-IE_CPU.onnx_model_resize10_import_only
-IE_CPU.onnx_resize10_down_scales_const_nearest
-IE_CPU.onnx_resize10_up_scales_const_linear
-IE_CPU.onnx_resize10_up_scales_const_nearest
-IE_CPU.onnx_resize11_scales_up_linear_asymmetric
-IE_CPU.onnx_resize11_scales_nearest_asymmetric_floor
IE_CPU.onnx_model_round
IE_CPU.onnx_upsample9_scales_const_linear_infer
IE_CPU.onnx_upsample9_scales_const_nearest_infer
IE_CPU.onnx_upsample8_import_only
IE_CPU.onnx_upsample9_scales_const_import_only
IE_CPU.onnx_empty_initializers_handling
-IE_CPU.onnx_resize11_scales_down_linear
IE_CPU.onnx_resize11_scales_nearest_asymmetric_floor_dynamic_sizes
-IE_CPU.onnx_resize11_sizes_nearest_asymmetric_floor
-IE_CPU.onnx_resize11_sizes_linear
# RNNCell operation has a form that is not supported
IE_CPU.onnx_model_rnn_defaults_fwd
# Temporarily disabled:
INTERPRETER.onnx_resize11_scales_nearest_asymmetric_floor_dynamic_sizes
-INTERPRETER.onnx_resize11_scales_down_linear
INTERPRETER.interpolate_down_scales_const_linear
INTERPRETER.onnx_resize10_up_scales_const_nearest
INTERPRETER.onnx_resize10_up_scales_const_linear