Files
openvino/ngraph/python/tests/test_onnx/test_onnx_external_data.py
Mateusz Bencer c0d71900fd Provide ONNX external data mechanism to ReadNetwork (#2588)
* added unit test

* added python test

* using pword approach

* Added passing path to onnx reader

* support for wstring

* Added more tests

* Apply suggestions from code review

Co-authored-by: Michał Karzyński <4430709+postrational@users.noreply.github.com>

* fix build for Windows

* styles applied

* Fixed Windows tests

* styles applied

* fixed styles in tests

* review remarks

* cmake order

* Used target_compile_definitions instead of add_definitions

* Move ONNX_TEST_MODELS to other scope

Co-authored-by: Michał Karzyński <4430709+postrational@users.noreply.github.com>
2020-10-14 12:30:53 +03:00

42 lines
1.5 KiB
Python

# ******************************************************************************
# Copyright 2017-2020 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ******************************************************************************
import os
import numpy as np
import ngraph as ng
from openvino.inference_engine import IECore
from tests.runtime import get_runtime
def test_import_onnx_with_external_data():
model_path = os.path.join(os.path.dirname(__file__), "models/external_data.prototxt")
ie = IECore()
ie_network = ie.read_network(model=model_path)
ng_function = ng.function_from_cnn(ie_network)
dtype = np.float32
value_a = np.array([1.0, 3.0, 5.0], dtype=dtype)
value_b = np.array([3.0, 5.0, 1.0], dtype=dtype)
# third input [5.0, 1.0, 3.0] read from external file
runtime = get_runtime()
computation = runtime.computation(ng_function)
result = computation(value_a, value_b)
assert np.allclose(result, np.array([3.0, 3.0, 3.0], dtype=dtype))