Skip to content

Commit 0670f23

Browse files
committed
adding OCM git submodule
1 parent bf51c44 commit 0670f23

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "ocm"]
2+
path = ocm
3+
url = https://github.com/intel/ocm

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ add_subdirectory(third-party)
198198
add_subdirectory(logging)
199199
add_subdirectory(ngraph_bridge)
200200
add_subdirectory(tools)
201+
add_subdirectory(ocm/OCM)
201202

202203
# The following targets depend on the Tensorflow source code directory
203204
# Get the absolute file name for the source

ngraph_bridge/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ target_link_libraries(
6969
absl_container
7070
absl_strings
7171
${InferenceEngine_LIBRARIES}
72+
ocm
7273
)
7374

7475
target_compile_definitions(
@@ -109,6 +110,7 @@ endif()
109110
set(IE_LIBS ${OPENVINO_ARTIFACTS_DIR}/deployment_tools/inference_engine/lib/intel64/)
110111
set(TBB_LIBS ${OPENVINO_ARTIFACTS_DIR}/deployment_tools/inference_engine/external/tbb/lib/)
111112
install(DIRECTORY ${IE_LIBS} DESTINATION "${NGTF_INSTALL_LIB_DIR}" )
113+
install(FILES ${CMAKE_INSTALL_PREFIX}/../ocm/OCM/libocm.so DESTINATION "${NGTF_INSTALL_LIB_DIR}")
112114
install(DIRECTORY ${TBB_LIBS} DESTINATION "${NGTF_INSTALL_LIB_DIR}" )
113115
if(USE_OPENVINO_FROM_LOCATION)
114116
file(GLOB NGRAPH_LIB_FILES "${IE_LIBS}/lib*" "${TBB_LIBS}/lib*")

ngraph_bridge/ngraph_rewrite_pass.cc

+26-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "ngraph_bridge/ngraph_mark_for_clustering.h"
3232
#include "ngraph_bridge/ngraph_utils.h"
3333

34+
#include "ocm/include/ocm_nodes_checker.h"
35+
3436
using namespace std;
3537

3638
namespace tensorflow {
@@ -104,7 +106,30 @@ class NGraphEncapsulationPass : public NGraphRewritePass {
104106

105107
// 1. Mark for clustering then, if requested, dump the graphs.
106108
std::set<string> skip_these_nodes = {};
107-
TF_RETURN_IF_ERROR(MarkForClustering(graph, skip_these_nodes));
109+
// TF_RETURN_IF_ERROR(MarkForClustering(graph, skip_these_nodes));
110+
111+
// OCM bypassing the MarkForClustering function call
112+
const char* device_id = std::getenv("NGRAPH_TF_BACKEND");
113+
if (device_id==nullptr){
114+
device_id = "CPU";
115+
}
116+
std::string ov_version = "2021_1";
117+
ocm::Framework_Names fName = ocm::Framework_Names::TF;
118+
ocm::FrameworkNodesChecker FC(fName, device_id, ov_version, options.graph->get());
119+
std::vector<void *> nodes_list = FC.MarkSupportedNodes();
120+
121+
// cast back the nodes in the TF format and mark the nodes for clustering (moved out from MarkForClustering function)
122+
const std::map<std::string, SetAttributesFunction>& set_attributes_map = GetAttributeSetters();
123+
for (auto void_node : nodes_list) {
124+
// TODO(amprocte): move attr name to a constant
125+
tensorflow::Node* node = (tensorflow::Node *)void_node;
126+
node->AddAttr("_ngraph_marked_for_clustering", true);
127+
auto it = set_attributes_map.find(node->type_string());
128+
if (it != set_attributes_map.end()) {
129+
it->second(node);
130+
}
131+
}
132+
108133
util::DumpTFGraph(graph, idx, "marked");
109134

110135
// 2. Assign clusters then, if requested, dump the graphs.

ocm

Submodule ocm added at 18c4aa6

test/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ target_link_libraries(
143143
tensorflow_ops_testutil
144144
absl_synchronization
145145
${InferenceEngine_LIBRARIES} ${TBB_IMPORTED_TARGETS}
146+
ocm
146147
)
147148

148149
# First install the libngraph_bridge.so and headers

0 commit comments

Comments
 (0)