summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKwanghoon Son <k.son@samsung.com>2020-03-12 12:23:43 +0900
committerKwanghoon Son <k.son@samsung.com>2020-03-12 12:23:43 +0900
commit947c030a9ec29478d652e21393115ac906aa7258 (patch)
tree685e3dfbbae724aa577e1f51dc7cf4261ae62904
parent858f3823e4983ff7f9afd6adadc25a1b19083d2f (diff)
downloadinference-engine-dldt-947c030a9ec29478d652e21393115ac906aa7258.tar.gz
inference-engine-dldt-947c030a9ec29478d652e21393115ac906aa7258.tar.bz2
inference-engine-dldt-947c030a9ec29478d652e21393115ac906aa7258.zip
Project initiationtizen
First commit for inference-engine-dldt Change-Id: Iac10d3ba7c358f957a41392eeb32d268ced986d4 Signed-off-by: Kwanghoon Son <k.son@samsung.com>
-rw-r--r--CMakeLists.txt11
-rw-r--r--LICENSE.APLv2204
-rw-r--r--NOTICE3
-rw-r--r--README.md1
-rw-r--r--inference-engine-dldt.manifest5
-rw-r--r--packaging/inference-engine-dldt.spec46
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/inference_engine_dldt.cpp392
-rw-r--r--src/inference_engine_dldt_private.h74
9 files changed, 739 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..3a41282
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,11 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "inference-engine-dldt")
+
+PROJECT(${fw_name})
+
+SET(dependents "dlog inference-engine-interface-common openvino")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name}_dep REQUIRED ${dependents})
+
+add_subdirectory(src)
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644
index 0000000..5554685
--- /dev/null
+++ b/LICENSE.APLv2
@@ -0,0 +1,204 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..0e0f016
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e0c806d
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# inference-engine-dldt
diff --git a/inference-engine-dldt.manifest b/inference-engine-dldt.manifest
new file mode 100644
index 0000000..a76fdba
--- /dev/null
+++ b/inference-engine-dldt.manifest
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
diff --git a/packaging/inference-engine-dldt.spec b/packaging/inference-engine-dldt.spec
new file mode 100644
index 0000000..961c1f9
--- /dev/null
+++ b/packaging/inference-engine-dldt.spec
@@ -0,0 +1,46 @@
+Name: inference-engine-dldt
+Summary: Intel Neural Network Runtime based implementation of inference-engine-interface
+Version: 0.0.1
+Release: 1
+Group: Multimedia/Libraries
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(inference-engine-interface-common)
+BuildRequires: pkgconfig(openvino)
+BuildRequires: pkgconfig(opencv) >= 3.4.1
+
+%description
+Intel Neural Network Runtime based implementation of inference-engine-interface
+
+%prep
+%setup -q
+
+%build
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+
+mkdir build
+pushd build
+cmake ..
+make %{?jobs:-j%jobs}
+popd
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/lib/
+install -m 666 build/src/*.so %{buildroot}/usr/lib
+
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%license LICENSE.APLv2
+%{_libdir}/*.so \ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..e7c804d
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,3 @@
+ADD_LIBRARY(${fw_name} SHARED inference_engine_dldt.cpp)
+target_include_directories(${fw_name} PUBLIC ${${fw_name}_dep_INCLUDE_DIRS})
+target_link_libraries(${fw_name} ${${fw_name}_dep_LIBRARIES}) \ No newline at end of file
diff --git a/src/inference_engine_dldt.cpp b/src/inference_engine_dldt.cpp
new file mode 100644
index 0000000..1660f39
--- /dev/null
+++ b/src/inference_engine_dldt.cpp
@@ -0,0 +1,392 @@
+/**
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#include <fstream>
+#include <iostream>
+#include <unistd.h>
+#include <time.h>
+#include <queue>
+
+#include <inference_engine_error.h>
+#include "inference_engine_dldt_private.h"
+
+/**
+ * Set in/output Layer property is not stable.
+ * Only 1 batch
+ * 1 layer assigned only 1 tensor
+ * If N layer == N tensor exist
+ */
+
+#define BATCH_SIZE (1)
+
+namespace InferenceEngineImpl
+{
+namespace DLDTImpl
+{
+
+int DataTypeToSize(size_t &rv, inference_tensor_data_type_e tType)
+{
+
+ switch (tType)
+ {
+ case TENSOR_DATA_TYPE_FLOAT32:
+ case TENSOR_DATA_TYPE_UINT32:
+ rv = 4;
+ break;
+
+ case TENSOR_DATA_TYPE_FLOAT16:
+ case TENSOR_DATA_TYPE_UINT16:
+ rv = 2;
+ break;
+
+ case TENSOR_DATA_TYPE_UINT8:
+ rv = 1;
+ break;
+
+ default:
+ LOGE("Unsupported data type");
+ return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
+ break;
+ }
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int PrecisionToDataType(inference_tensor_data_type_e &rv, const InferenceEngine::Precision &prec)
+{
+ switch (InferenceEngine::Precision::ePrecision(prec))
+ {
+ case InferenceEngine::Precision::ePrecision::FP32:
+ rv = TENSOR_DATA_TYPE_FLOAT32;
+ break;
+
+ case InferenceEngine::Precision::ePrecision::FP16:
+ rv = TENSOR_DATA_TYPE_FLOAT16;
+ break;
+
+ case InferenceEngine::Precision::ePrecision::U8:
+ rv = TENSOR_DATA_TYPE_UINT8;
+ break;
+
+ case InferenceEngine::Precision::ePrecision::U16:
+ rv = TENSOR_DATA_TYPE_UINT16;
+ break;
+
+ case InferenceEngine::Precision::ePrecision::I32:
+ rv = TENSOR_DATA_TYPE_UINT32;
+ break;
+
+ default:
+ LOGE("Unsupported data type");
+ return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
+ break;
+ }
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int LayoutToShapeType(inference_tensor_shape_type_e &rv, InferenceEngine::Layout layout)
+{
+ switch (layout)
+ {
+ case InferenceEngine::NCHW:
+ rv = TENSOR_SHAPE_NCHW;
+ break;
+
+ case InferenceEngine::NHWC:
+ rv = TENSOR_SHAPE_NHWC;
+ break;
+ default:
+ LOGE("Unsupported tensor shape type");
+ return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
+ break;
+ }
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+InferenceDLDT::InferenceDLDT()
+{
+}
+InferenceDLDT::~InferenceDLDT()
+{
+}
+
+int InferenceDLDT::SetTargetDevices(int types)
+{
+ LOGI("ENTER");
+
+ mTargetDevice = 0;
+ LOGI("Inference targets are, ");
+ if (types & INFERENCE_TARGET_CUSTOM)
+ {
+ mTargetDevice |= INFERENCE_TARGET_CUSTOM;
+ LOGI("MYRIAD ONLY");
+ }
+
+ LOGI("LEAVE");
+
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int DLDTDataToTensorInfo(inference_engine_tensor_info &tensor_info, InferenceEngine::DataPtr data_ptr)
+{
+ PrecisionToDataType(tensor_info.data_type, data_ptr->getPrecision());
+ const InferenceEngine::SizeVector sizev = data_ptr->getTensorDesc().getDims();
+ tensor_info.shape = std::vector<int>(sizev.begin(), sizev.end());
+ LayoutToShapeType(tensor_info.shape_type, data_ptr->getLayout());
+
+ if (tensor_info.shape[0] != BATCH_SIZE)
+ {
+ LOGE("Batch size should be 1");
+ return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
+ }
+
+ size_t shape_size = 1;
+ for (auto &it : tensor_info.shape)
+ {
+ shape_size *= it;
+ }
+
+ tensor_info.size = shape_size;
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int InferenceDLDT::Load(std::vector<std::string> model_paths, inference_model_format_e model_format)
+{
+ LOGI("ENTER");
+
+ if (!(mTargetDevice == INFERENCE_TARGET_CUSTOM && model_format == INFERENCE_MODEL_DLDT))
+ {
+ LOGE("Only myriad is supported with xml format, set target to custom");
+ return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
+ }
+
+ std::string input_model = model_paths[0];
+ InferenceEngine::CNNNetReader networkReader;
+ networkReader.ReadNetwork(input_model);
+ networkReader.ReadWeights(input_model.substr(0, input_model.size() - 4) + ".bin");
+ InferenceEngine::CNNNetwork network = networkReader.getNetwork();
+ network.setBatchSize(BATCH_SIZE);
+
+ InferenceEngine::Core DLDTCore;
+ InferenceEngine::ExecutableNetwork exeNetwork;
+ try
+ {
+ exeNetwork = DLDTCore.LoadNetwork(network, "MYRIAD");
+ }
+ catch (const std::exception &e)
+ {
+ LOGE("Fail to load Myriad");
+ return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
+ }
+
+ mInferRequest = exeNetwork.CreateInferRequest();
+
+ // set input
+ InferenceEngine::InputsDataMap inputInfo = network.getInputsInfo();
+ for (auto ele : inputInfo)
+ {
+ mInputProperty.layer_names.push_back(ele.first);
+ inference_engine_tensor_info tinfo;
+ DLDTDataToTensorInfo(tinfo, ele.second->getInputData());
+ mInputProperty.tensor_infos.push_back(tinfo);
+ }
+
+ // set output
+ InferenceEngine::OutputsDataMap outputInfo = network.getOutputsInfo();
+ for (auto ele : outputInfo)
+ {
+ mOutputProperty.layer_names.push_back(ele.first);
+ inference_engine_tensor_info tinfo;
+ DLDTDataToTensorInfo(tinfo, ele.second);
+ mOutputProperty.tensor_infos.push_back(tinfo);
+ }
+
+ LOGI("LEAVE");
+
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int InferenceDLDT::GetInputTensorBuffers(std::vector<inference_engine_tensor_buffer> &buffers)
+{
+ LOGI("ENTER");
+
+ // Upper layer will allocate output tensor buffer/buffers.
+
+ LOGI("LEAVE");
+
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int InferenceDLDT::GetOutputTensorBuffers(std::vector<inference_engine_tensor_buffer> &buffers)
+{
+ LOGI("ENTER");
+
+ // Upper layer will allocate output tensor buffer/buffers.
+
+ LOGI("LEAVE");
+
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int InferenceDLDT::GetInputLayerProperty(inference_engine_layer_property &property)
+{
+ LOGI("ENTER");
+
+ property = mInputProperty;
+
+ LOGI("LEAVE");
+
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int InferenceDLDT::GetOutputLayerProperty(inference_engine_layer_property &property)
+{
+ LOGI("ENTER");
+
+ property = mOutputProperty;
+
+ LOGI("LEAVE");
+
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int InferenceDLDT::SetInputLayerProperty(inference_engine_layer_property &property)
+{
+ LOGI("ENTER");
+
+ mInputProperty = property;
+
+ LOGI("LEAVE");
+
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int InferenceDLDT::SetOutputLayerProperty(inference_engine_layer_property &property)
+{
+ LOGI("ENTER");
+
+ mOutputProperty = property;
+
+ LOGI("LEAVE");
+
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int InferenceDLDT::GetBackendCapacity(inference_engine_capacity *capacity)
+{
+ LOGI("ENTER");
+
+ if (capacity == NULL)
+ {
+ LOGE("Bad pointer.");
+ return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER;
+ }
+
+ capacity->supported_accel_devices = mTargetDevice;
+
+ LOGI("LEAVE");
+
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+int TypeToBlob(const InferenceEngine::TensorDesc &tensorDesc, void *ptr, size_t size, InferenceEngine::Blob::Ptr &out)
+{
+ switch (InferenceEngine::Precision::ePrecision(tensorDesc.getPrecision()))
+ {
+ case InferenceEngine::Precision::ePrecision::FP32:
+ out = InferenceEngine::make_shared_blob<float>(tensorDesc, (float *)ptr, size);
+ break;
+
+ case InferenceEngine::Precision::ePrecision::U8:
+ out = InferenceEngine::make_shared_blob<uint8_t>(tensorDesc, (uint8_t *)ptr, size);
+ break;
+
+ case InferenceEngine::Precision::ePrecision::U16:
+ case InferenceEngine::Precision::ePrecision::FP16:
+ out = InferenceEngine::make_shared_blob<uint16_t>(tensorDesc, (uint16_t *)ptr, size);
+ break;
+
+ case InferenceEngine::Precision::ePrecision::I32:
+ out = InferenceEngine::make_shared_blob<int32_t>(tensorDesc, (int32_t *)ptr, size);
+ break;
+
+ default:
+ LOGE("Unsupported data type");
+ return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
+ break;
+ }
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+int InferenceDLDT::Run(std::vector<inference_engine_tensor_buffer> &input_buffers,
+ std::vector<inference_engine_tensor_buffer> &output_buffers)
+{
+ LOGI("ENTER");
+
+ if (mTargetDevice != INFERENCE_TARGET_CUSTOM)
+ {
+ LOGE("Only myriad is supported, set target to custom");
+ return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
+ }
+
+ if (mInputProperty.layer_names.size() != input_buffers.size() ||
+ mOutputProperty.layer_names.size() != output_buffers.size())
+ {
+ return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER;
+ }
+
+ for (size_t i = 0; i < input_buffers.size(); i++)
+ {
+ InferenceEngine::Blob::Ptr imgBlob = mInferRequest.GetBlob(mInputProperty.layer_names[i]);
+ const InferenceEngine::TensorDesc tDesc = imgBlob->getTensorDesc();
+ InferenceEngine::Blob::Ptr input;
+ TypeToBlob(tDesc, input_buffers[i].buffer, input_buffers[i].size, input);
+ mInferRequest.SetBlob(mInputProperty.layer_names[i], input);
+ }
+
+ mInferRequest.Infer();
+ for (size_t i = 0; i < output_buffers.size(); i++)
+ {
+ InferenceEngine::Blob::Ptr output = mInferRequest.GetBlob(mOutputProperty.layer_names[i]);
+ std::memcpy(output->cbuffer().as<void *>(), output_buffers[i].buffer, output_buffers[i].size);
+ }
+
+ LOGI("LEAVE");
+ return INFERENCE_ENGINE_ERROR_NONE;
+}
+
+extern "C"
+{
+ class IInferenceEngineCommon *EngineCommonInit(void)
+ {
+ LOGI("ENTER");
+
+ InferenceDLDT *engine = new InferenceDLDT();
+
+ LOGI("LEAVE");
+
+ return engine;
+ }
+
+ void EngineCommonDestroy(class IInferenceEngineCommon *engine)
+ {
+ LOGI("ENTER");
+
+ delete engine;
+
+ LOGI("LEAVE");
+ }
+}
+} // namespace DLDTImpl
+} // namespace InferenceEngineImpl
diff --git a/src/inference_engine_dldt_private.h b/src/inference_engine_dldt_private.h
new file mode 100644
index 0000000..4a7c2a6
--- /dev/null
+++ b/src/inference_engine_dldt_private.h
@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __INFERENCE_ENGINE_DLDT_PRIVATE_H__
+#define __INFERENCE_ENGINE_DLDT_PRIVATE_H__
+
+#include <inference_engine_common.h>
+#include <inference_engine.hpp> /** DLDT inference engine */
+#include <memory>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "INFERENCE_ENGINE_DLDT"
+
+using namespace InferenceEngineInterface::Common;
+
+namespace InferenceEngineImpl
+{
+namespace DLDTImpl
+{
+
+class InferenceDLDT : public IInferenceEngineCommon
+{
+public:
+ InferenceDLDT();
+ ~InferenceDLDT();
+
+ int SetTargetDevices(int types) override;
+
+ int Load(std::vector<std::string> model_paths, inference_model_format_e model_format) override;
+
+ int GetInputTensorBuffers(std::vector<inference_engine_tensor_buffer> &buffers) override;
+
+ int GetOutputTensorBuffers(std::vector<inference_engine_tensor_buffer> &buffers) override;
+
+ int GetInputLayerProperty(inference_engine_layer_property &property) override;
+
+ int GetOutputLayerProperty(inference_engine_layer_property &property) override;
+
+ int SetInputLayerProperty(inference_engine_layer_property &property) override;
+
+ int SetOutputLayerProperty(inference_engine_layer_property &property) override;
+
+ int GetBackendCapacity(inference_engine_capacity *capacity) override;
+
+ int Run(std::vector<inference_engine_tensor_buffer> &input_buffers,
+ std::vector<inference_engine_tensor_buffer> &output_buffers) override;
+
+private:
+ int mTargetDevice;
+ InferenceEngine::InferRequest mInferRequest;
+ inference_engine_layer_property mInputProperty;
+ inference_engine_layer_property mOutputProperty;
+};
+
+} // namespace DLDTImpl
+} // namespace InferenceEngineImpl
+
+#endif /* __INFERENCE_ENGINE_DLDT_PRIVATE_H__ */