Skip to content

Commit

Permalink
OpenVINO tries to use GPU first, if that doesn't work it switches to CPU
Browse files Browse the repository at this point in the history
  • Loading branch information
smistad committed Jan 8, 2019
1 parent 63ed3cd commit 222cbb9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions source/FAST/Algorithms/NeuralNetwork/OpenVINOEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ void OpenVINOEngine::run() {
node.second.data = tensor;
}
}

void OpenVINOEngine::load() {
void OpenVINOEngine::loadPlugin(std::string deviceType) {
PluginDispatcher dispatcher({""});
InferencePlugin plugin(dispatcher.getSuitablePlugin(TargetDevice::eCPU));
InferencePlugin plugin(dispatcher.getPluginByDevice(deviceType));
reportInfo() << "OpenVINO: Inference plugin setup complete." << reportEnd();

// --------------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------
Expand Down Expand Up @@ -113,6 +112,17 @@ void OpenVINOEngine::load() {
reportInfo() << "OpenVINO: Network fully loaded." << reportEnd();
}

void OpenVINOEngine::load() {
try {
loadPlugin(getDeviceName(TargetDevice::eGPU));
} catch(::InferenceEngine::details::InferenceEngineException &e) {
reportInfo() << "Failed to get GPU plugin for OpenVINO inference engine: " << e.what() << reportEnd();
reportInfo() << "Selecting CPU plugin instead.." << reportEnd();
loadPlugin(getDeviceName(TargetDevice::eCPU));
}

}

ImageOrdering OpenVINOEngine::getPreferredImageOrdering() const {
return ImageOrdering::CHW;
}
Expand Down
1 change: 1 addition & 0 deletions source/FAST/Algorithms/NeuralNetwork/OpenVINOEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class OpenVINOEngine : public InferenceEngine {

private:
std::shared_ptr<::InferenceEngine::InferRequest> m_inferRequest;
void loadPlugin(std::string deviceType);
};

}

0 comments on commit 222cbb9

Please sign in to comment.