Fixed creation of C++ wrappers from old API (#5805)
This commit is contained in:
parent
ffc9c95a2b
commit
ffe03b6ed3
@ -12,7 +12,7 @@
|
|||||||
namespace InferenceEngine {
|
namespace InferenceEngine {
|
||||||
|
|
||||||
#define EXEC_NET_CALL_STATEMENT(...) \
|
#define EXEC_NET_CALL_STATEMENT(...) \
|
||||||
if (_impl == nullptr) IE_THROW() << "ExecutableNetwork was not initialized."; \
|
if (_impl == nullptr) IE_THROW(NotAllocated) << "ExecutableNetwork was not initialized."; \
|
||||||
try { \
|
try { \
|
||||||
__VA_ARGS__; \
|
__VA_ARGS__; \
|
||||||
} catch(...) {details::Rethrow();}
|
} catch(...) {details::Rethrow();}
|
||||||
@ -27,10 +27,14 @@ IE_SUPPRESS_DEPRECATED_START
|
|||||||
|
|
||||||
ExecutableNetwork::ExecutableNetwork(IExecutableNetwork::Ptr exec,
|
ExecutableNetwork::ExecutableNetwork(IExecutableNetwork::Ptr exec,
|
||||||
std::shared_ptr<details::SharedObjectLoader> splg)
|
std::shared_ptr<details::SharedObjectLoader> splg)
|
||||||
: _so(*splg), _impl(), actual(exec) {
|
: _so(), _impl(), actual(exec) {
|
||||||
|
if (splg) {
|
||||||
|
_so = *splg;
|
||||||
|
}
|
||||||
|
|
||||||
// plg can be null, but not the actual
|
// plg can be null, but not the actual
|
||||||
if (actual == nullptr)
|
if (actual == nullptr)
|
||||||
IE_THROW() << "ExecutableNetwork was not initialized.";
|
IE_THROW(NotAllocated) << "ExecutableNetwork was not initialized.";
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstOutputsDataMap ExecutableNetwork::GetOutputsInfo() const {
|
ConstOutputsDataMap ExecutableNetwork::GetOutputsInfo() const {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
namespace InferenceEngine {
|
namespace InferenceEngine {
|
||||||
|
|
||||||
#define INFER_REQ_CALL_STATEMENT(...) \
|
#define INFER_REQ_CALL_STATEMENT(...) \
|
||||||
if (_impl == nullptr) IE_THROW() << "Inference Request is not initialized"; \
|
if (_impl == nullptr) IE_THROW(NotAllocated) << "Inference Request is not initialized"; \
|
||||||
try { \
|
try { \
|
||||||
__VA_ARGS__ \
|
__VA_ARGS__ \
|
||||||
} catch(...) {details::Rethrow();}
|
} catch(...) {details::Rethrow();}
|
||||||
@ -31,10 +31,14 @@ IE_SUPPRESS_DEPRECATED_START
|
|||||||
|
|
||||||
InferRequest::InferRequest(IInferRequest::Ptr request,
|
InferRequest::InferRequest(IInferRequest::Ptr request,
|
||||||
std::shared_ptr<details::SharedObjectLoader> splg)
|
std::shared_ptr<details::SharedObjectLoader> splg)
|
||||||
: _so(*splg), _impl(), actual(request) {
|
: _so(), _impl(), actual(request) {
|
||||||
|
if (splg) {
|
||||||
|
_so = *splg;
|
||||||
|
}
|
||||||
|
|
||||||
// plg can be null, but not the actual
|
// plg can be null, but not the actual
|
||||||
if (actual == nullptr)
|
if (actual == nullptr)
|
||||||
IE_THROW() << "InferRequest was not initialized.";
|
IE_THROW(NotAllocated) << "InferRequest was not initialized.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void InferRequest::SetBlob(const std::string& name, const Blob::Ptr& data) {
|
void InferRequest::SetBlob(const std::string& name, const Blob::Ptr& data) {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "exception2status.hpp"
|
#include "exception2status.hpp"
|
||||||
|
|
||||||
#define VARIABLE_CALL_STATEMENT(...) \
|
#define VARIABLE_CALL_STATEMENT(...) \
|
||||||
if (_impl == nullptr) IE_THROW() << "VariableState was not initialized."; \
|
if (_impl == nullptr) IE_THROW(NotAllocated) << "VariableState was not initialized."; \
|
||||||
try { \
|
try { \
|
||||||
__VA_ARGS__; \
|
__VA_ARGS__; \
|
||||||
} catch(...) {details::Rethrow();}
|
} catch(...) {details::Rethrow();}
|
||||||
@ -26,10 +26,14 @@ IE_SUPPRESS_DEPRECATED_START
|
|||||||
|
|
||||||
VariableState::VariableState(std::shared_ptr<IVariableState> state,
|
VariableState::VariableState(std::shared_ptr<IVariableState> state,
|
||||||
std::shared_ptr<details::SharedObjectLoader> splg)
|
std::shared_ptr<details::SharedObjectLoader> splg)
|
||||||
: _so(*splg), _impl(), actual(state) {
|
: _so(), _impl(), actual(state) {
|
||||||
|
if (splg) {
|
||||||
|
_so = *splg;
|
||||||
|
}
|
||||||
|
|
||||||
// plg can be null, but not the actual
|
// plg can be null, but not the actual
|
||||||
if (actual == nullptr)
|
if (actual == nullptr)
|
||||||
IE_THROW() << "VariableState was not initialized.";
|
IE_THROW(NotAllocated) << "VariableState was not initialized.";
|
||||||
}
|
}
|
||||||
|
|
||||||
Blob::CPtr VariableState::GetLastState() const {
|
Blob::CPtr VariableState::GetLastState() const {
|
||||||
|
@ -5,84 +5,98 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <cpp/ie_infer_request.hpp>
|
#include <cpp/ie_infer_request.hpp>
|
||||||
|
#include "unit_test_utils/mocks/mock_iinfer_request.hpp"
|
||||||
|
|
||||||
using namespace ::testing;
|
using namespace ::testing;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace InferenceEngine;
|
using namespace InferenceEngine;
|
||||||
using namespace InferenceEngine::details;
|
using namespace InferenceEngine::details;
|
||||||
|
|
||||||
|
IE_SUPPRESS_DEPRECATED_START
|
||||||
|
|
||||||
|
TEST(InferRequestCPPTests, throwsOnUninitialized) {
|
||||||
|
std::shared_ptr<IInferRequest> ptr;
|
||||||
|
ASSERT_THROW(InferRequest req(ptr), InferenceEngine::NotAllocated);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(InferRequestCPPTests, nothrowOnInitialized) {
|
||||||
|
std::shared_ptr<IInferRequest> ptr = std::make_shared<MockIInferRequest>();
|
||||||
|
ASSERT_NO_THROW(InferRequest req(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
IE_SUPPRESS_DEPRECATED_END
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedSetBlob) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedSetBlob) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.SetBlob({}, {}), InferenceEngine::Exception);
|
ASSERT_THROW(req.SetBlob({}, {}), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedGetBlob) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedGetBlob) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.GetBlob({}), InferenceEngine::Exception);
|
ASSERT_THROW(req.GetBlob({}), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedSetBlobPreproc) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedSetBlobPreproc) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.SetBlob({}, {}, {}), InferenceEngine::Exception);
|
ASSERT_THROW(req.SetBlob({}, {}, {}), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedGetPreProcess) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedGetPreProcess) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.GetPreProcess({}), InferenceEngine::Exception);
|
ASSERT_THROW(req.GetPreProcess({}), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedInfer) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedInfer) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.Infer(), InferenceEngine::Exception);
|
ASSERT_THROW(req.Infer(), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedGetPerformanceCounts) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedGetPerformanceCounts) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.GetPerformanceCounts(), InferenceEngine::Exception);
|
ASSERT_THROW(req.GetPerformanceCounts(), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedSetInput) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedSetInput) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.SetInput({{}}), InferenceEngine::Exception);
|
ASSERT_THROW(req.SetInput({{}}), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedSetOutput) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedSetOutput) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.SetOutput({{}}), InferenceEngine::Exception);
|
ASSERT_THROW(req.SetOutput({{}}), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedSetBatch) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedSetBatch) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.SetBatch({}), InferenceEngine::Exception);
|
ASSERT_THROW(req.SetBatch({}), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedStartAsync) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedStartAsync) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.StartAsync(), InferenceEngine::Exception);
|
ASSERT_THROW(req.StartAsync(), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedWait) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedWait) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.Wait({}), InferenceEngine::Exception);
|
ASSERT_THROW(req.Wait({}), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedSetCompletionCallback) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedSetCompletionCallback) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
std::function<void(InferRequest, StatusCode)> f;
|
std::function<void(InferRequest, StatusCode)> f;
|
||||||
ASSERT_THROW(req.SetCompletionCallback(f), InferenceEngine::Exception);
|
ASSERT_THROW(req.SetCompletionCallback(f), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
IE_SUPPRESS_DEPRECATED_START
|
IE_SUPPRESS_DEPRECATED_START
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedCast) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedCast) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW((void)static_cast<IInferRequest::Ptr>(req), InferenceEngine::Exception);
|
ASSERT_THROW((void)static_cast<IInferRequest::Ptr>(req), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
IE_SUPPRESS_DEPRECATED_END
|
IE_SUPPRESS_DEPRECATED_END
|
||||||
|
|
||||||
TEST(InferRequestCPPTests, throwsOnUninitializedQueryState) {
|
TEST(InferRequestCPPTests, throwsOnUninitializedQueryState) {
|
||||||
InferRequest req;
|
InferRequest req;
|
||||||
ASSERT_THROW(req.QueryState(), InferenceEngine::Exception);
|
ASSERT_THROW(req.QueryState(), InferenceEngine::NotAllocated);
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,27 @@
|
|||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <cpp/ie_executable_network.hpp>
|
#include <cpp/ie_executable_network.hpp>
|
||||||
|
#include "unit_test_utils/mocks/mock_iexecutable_network.hpp"
|
||||||
|
|
||||||
using namespace ::testing;
|
using namespace ::testing;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace InferenceEngine;
|
using namespace InferenceEngine;
|
||||||
using namespace InferenceEngine::details;
|
using namespace InferenceEngine::details;
|
||||||
|
|
||||||
|
IE_SUPPRESS_DEPRECATED_START
|
||||||
|
|
||||||
|
TEST(ExecutableNetworkTests, throwsOnUninitialized) {
|
||||||
|
std::shared_ptr<IExecutableNetwork> ptr;
|
||||||
|
ASSERT_THROW(ExecutableNetwork req(ptr), InferenceEngine::NotAllocated);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(ExecutableNetworkTests, nothrowOnInitialized) {
|
||||||
|
std::shared_ptr<IExecutableNetwork> ptr = std::make_shared<MockIExecutableNetwork>();
|
||||||
|
ASSERT_NO_THROW(ExecutableNetwork req(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
IE_SUPPRESS_DEPRECATED_END
|
||||||
|
|
||||||
TEST(ExecutableNetworkTests, throwsOnUninitializedGetOutputsInfo) {
|
TEST(ExecutableNetworkTests, throwsOnUninitializedGetOutputsInfo) {
|
||||||
ExecutableNetwork exec;
|
ExecutableNetwork exec;
|
||||||
ASSERT_THROW(exec.GetOutputsInfo(), InferenceEngine::Exception);
|
ASSERT_THROW(exec.GetOutputsInfo(), InferenceEngine::Exception);
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (C) 2018-2021 Intel Corporation
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <cpp/ie_infer_request.hpp>
|
||||||
|
#include "unit_test_utils/mocks/mock_ie_ivariable_state.hpp"
|
||||||
|
|
||||||
|
using namespace ::testing;
|
||||||
|
using namespace std;
|
||||||
|
using namespace InferenceEngine;
|
||||||
|
using namespace InferenceEngine::details;
|
||||||
|
|
||||||
|
IE_SUPPRESS_DEPRECATED_START
|
||||||
|
|
||||||
|
TEST(VariableStateCPPTests, throwsOnUninitialized) {
|
||||||
|
std::shared_ptr<IVariableState> ptr;
|
||||||
|
ASSERT_THROW(VariableState var(ptr), InferenceEngine::NotAllocated);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(VariableStateCPPTests, nothrowOnInitialized) {
|
||||||
|
std::shared_ptr<IVariableState> ptr = std::make_shared<MockIVariableState>();
|
||||||
|
ASSERT_NO_THROW(VariableState var(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(VariableStateCPPTests, throwsOnUninitializedGetLastState) {
|
||||||
|
VariableState req;
|
||||||
|
ASSERT_THROW(req.GetLastState(), InferenceEngine::NotAllocated);
|
||||||
|
}
|
||||||
|
|
||||||
|
IE_SUPPRESS_DEPRECATED_END
|
||||||
|
|
||||||
|
TEST(VariableStateCPPTests, throwsOnUninitializedReset) {
|
||||||
|
VariableState req;
|
||||||
|
ASSERT_THROW(req.Reset(), InferenceEngine::NotAllocated);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(VariableStateCPPTests, throwsOnUninitializedGetname) {
|
||||||
|
VariableState req;
|
||||||
|
ASSERT_THROW(req.GetName(), InferenceEngine::NotAllocated);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(VariableStateCPPTests, throwsOnUninitializedGetState) {
|
||||||
|
VariableState req;
|
||||||
|
ASSERT_THROW(req.GetState(), InferenceEngine::NotAllocated);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(VariableStateCPPTests, throwsOnUninitializedSetState) {
|
||||||
|
VariableState req;
|
||||||
|
Blob::Ptr blob;
|
||||||
|
ASSERT_THROW(req.SetState(blob), InferenceEngine::NotAllocated);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user