Skip to content

Commit b4f9f3f

Browse files
author
Shrestha Malik
authored
Merge pull request #453 from tensorflow/shrestha/fix_pip
Shrestha/fix pip
2 parents edb381d + a7db58c commit b4f9f3f

18 files changed

+890
-480
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Once TensorFlow's dependencies are installed, clone the `ngraph-bridge` repo:
8888

8989
git clone https://github.com/tensorflow/ngraph-bridge.git
9090
cd ngraph-bridge
91-
git checkout v0.22.0-rc3
91+
git checkout v0.22.0-rc4
9292

9393
Run the following Python script to build TensorFlow, nGraph, and the bridge. Use Python 3.5:
9494

ngraph_bridge/enable_variable_ops/ngraph_capture_variables.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ Status CaptureVariables(Graph* graph, std::set<string> skip_these_nodes) {
114114
// If Prefetch is requested
115115
if (std::getenv(NGraphPrefetchSharedResouce::NGRAPH_TF_USE_PREFETCH) !=
116116
nullptr) {
117+
if (make_iterator_nodes.size() == 0) {
118+
// No MakeIterator Op found in the Graph
119+
make_iterator_nodes.clear();
120+
nodes_to_capture.clear();
121+
return Status::OK();
122+
}
123+
117124
if (make_iterator_nodes.size() > 1) {
118125
return errors::Internal(
119126
"Found more than 1 MakeIterator nodes. This case is not supported.");

ngraph_bridge/ngraph_encapsulate_clusters.cc

Lines changed: 565 additions & 472 deletions
Large diffs are not rendered by default.

ngraph_bridge/ngraph_encapsulate_clusters.h

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include <iostream>
2727
#include "tensorflow/core/graph/graph.h"
2828

29+
#include "ngraph/ngraph.hpp"
30+
31+
#include "ngraph_bridge/ngraph_partial_shapes.h"
32+
2933
namespace tensorflow {
3034

3135
namespace ngraph_bridge {
@@ -35,10 +39,110 @@ typedef std::map<std::string, std::vector<int>> ShapeHintMap;
3539
// the integer represent AOT level requested.
3640
typedef std::pair<bool, std::set<ShapeHintMap>> AOTInfo;
3741

42+
// TODO: an optimization would be to separate the analysis and rewriting passes
43+
// cleanly, so that analysis pass is run in mark_for_clustering, and its
44+
// information is reused here instead of recalculating
45+
// To do that an Encapsulator object with AnalysisPass run can be created in
46+
// MarkForClustering, and that can be passed to EncapsulateClusters
47+
48+
/// Takes a TF graph where ngraph_cluster attributes has been marked in a
49+
/// preceeding pass (assign_clusters), then replaces TF subgraphs and inserts
50+
/// encapsulate ops in their place. Optionally can perform ahead of time
51+
/// compilation.
3852
Status EncapsulateClusters(
3953
Graph* graph, int graph_id, FunctionDefLibrary* fdeflib,
40-
std::unordered_map<std::string, std::string> device_config,
41-
AOTInfo aot_info);
54+
const std::unordered_map<std::string, std::string>& device_config,
55+
const AOTInfo& aot_info);
56+
57+
// TODO Encapsulator is dependent on ClusterManager. They could be made
58+
// independent.
59+
60+
// A class to perform analysis (identify subgraphs)
61+
// and rewriting (create encapsulates and splice them in)
62+
// Order of calling: construction -> AnalysisPass -> RewritePass
63+
// |
64+
// v
65+
// NewClusterIds
66+
// Any other order of calling will generate errors
67+
// Cannot be copied/moved or reset
68+
class Encapsulator {
69+
public:
70+
Encapsulator(Graph* g);
71+
// Populate ClusterManager with the subgraphs for each potential encapsulate
72+
Status AnalysisPass();
73+
// Perform the actual graph surgery
74+
Status RewritePass(
75+
FunctionDefLibrary* fdeflib, int graph_id,
76+
const std::unordered_map<std::string, std::string>& device_config);
77+
// Returns the newly created cluster ids after AnalysisPass is done
78+
// Needed because ClusterManager (CM) might have contained old stuff,
79+
// so it might not be possible to query the CM itself to get this
80+
Status GetNewClusterIDs(std::set<int>& result);
81+
82+
Encapsulator(const Encapsulator&) = delete;
83+
Encapsulator(Encapsulator&&) = delete;
84+
Encapsulator& operator=(const Encapsulator&) = delete;
85+
Encapsulator& operator=(Encapsulator&&) = delete;
86+
87+
private:
88+
Graph* graph;
89+
// boolean to indicate if analysis has been done
90+
// If not rewritepass should not be called
91+
bool analysis_done;
92+
// boolean to indicate that rewrite is done;
93+
bool rewrite_done;
94+
// A map from cluster indices to the expected device name for nodes
95+
// in that cluster.
96+
std::map<int, std::string> device_name_map;
97+
98+
// We *should* eventually have a way of monitoring the device and the backend
99+
// together
100+
std::map<int, std::string> backend_name_map;
101+
102+
// As we build the graph we will be tracking the.. TODO(amprocte): finish
103+
// this comment.
104+
std::map<std::tuple<int, int>, std::tuple<int, int>> output_remap_map;
105+
std::map<std::tuple<int, int, int>, int> input_remap_map;
106+
std::map<std::tuple<int, std::string, int>, string> input_rename_map;
107+
108+
// A map from cluster indices to a vector of input data types.
109+
std::map<int, std::vector<std::tuple<int, int, DataType>>> cluster_input_map;
110+
// A map from cluster indices to a vector of output data types.
111+
std::map<int, std::vector<DataType>> cluster_output_dt_map;
112+
113+
// A map from cluster indices to corresponding NGraphEncapsulate nodes.
114+
std::map<int, Node*> cluster_node_map;
115+
116+
std::set<int> cluster_indices_for_this_graph;
117+
118+
static void AddInput(NodeDef* dst, StringPiece src_name, int src_slot);
119+
};
120+
121+
// Translates TF subgraph to ng function then compiles it
122+
Status PerformAOTOnEncapsulates(Graph* graph, const AOTInfo& aot_info);
123+
124+
std::string HintAsString(ShapeHintMap single_hint);
125+
126+
// Given a node, partialshape info from TF (present in the .pb itself) and a
127+
// shape hint, combine all that information
128+
PartialShape CombineNodeInfoAndHint(Node* node,
129+
PartialShape partial_shape_from_node,
130+
const ShapeHintMap& single_hint);
131+
132+
// Given a TF graph, it scans it for inputs and finds what TF is saying about
133+
// their shapes (in the .pb itself)
134+
// Creates a map between input node names and PartialShape information we get
135+
// from the TF graph
136+
std::map<std::string, PartialShape> GetShapesFromTFInputnodes(
137+
Graph* graph, const string& input_node_type);
138+
139+
// Given an encapsulate node, and the input shapes,
140+
// performs TranslateGraph and returns an ng function and a signature
141+
Status PerformTranslation(Node* node,
142+
const std::map<std::string, std::vector<int>>&
143+
inputs_node_shapes_for_compilation,
144+
std::string& signature,
145+
std::shared_ptr<ngraph::Function>& ng_function);
42146

43147
} // namespace ngraph_bridge
44148
} // namespace tensorflow

ngraph_bridge/version.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// candidate such as v0.7.0-rc0
3333
// The code in master will always have the last released version number
3434
// with a suffix of '-master'
35-
#define NG_TF_VERSION_SUFFIX "-rc3"
35+
#define NG_TF_VERSION_SUFFIX "-rc4"
3636

3737
#define VERSION_STR_HELPER(x) #x
3838
#define VERSION_STR(x) VERSION_STR_HELPER(x)

python/setup.in.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def get_tag(self):
5959

6060
setup(
6161
name='ngraph_tensorflow_bridge',
62-
version='0.22.0rc3',
62+
version='0.22.0rc4',
6363
description='Intel nGraph compiler and runtime for TensorFlow',
6464
long_description=long_description,
6565
long_description_content_type="text/markdown",

test/ci/buildkite/ngtf-cpu_centos-grappler.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
source /localdisk/buildkite/artifacts/$BUILDKITE_BUILD_ID/venv/bin/activate
5757
pip install psutil && pip install -U \
5858
/localdisk/buildkite/artifacts/$BUILDKITE_BUILD_ID/tensorflow/tensorflow-1.14.0-cp36-cp36m-linux_x86_64.whl
59+
pip install -U pip==19.3.1
5960
pip install -U /localdisk/buildkite/artifacts/$BUILDKITE_BUILD_ID/ngraph_tensorflow_bridge-*.whl
6061
6162
label: ":gear: Install"

test/ci/buildkite/ngtf-cpu_centos.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
source /localdisk/buildkite/artifacts/$BUILDKITE_BUILD_ID/venv/bin/activate
5656
pip install psutil && pip install -U \
5757
/localdisk/buildkite/artifacts/$BUILDKITE_BUILD_ID/tensorflow/tensorflow-1.14.0-cp36-cp36m-linux_x86_64.whl
58+
pip install -U pip==19.3.1
5859
pip install -U /localdisk/buildkite/artifacts/$BUILDKITE_BUILD_ID/ngraph_tensorflow_bridge-*.whl
5960
6061
label: ":gear: Install"

test/ci/buildkite/ngtf-cpu_macos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
source /usr/local/var/buildkite-agent/artifacts/$BUILDKITE_BUILD_ID/venv/bin/activate
4040
pip install -U \
4141
/usr/local/var/buildkite-agent/tf_1.14.0_install/artifacts/tensorflow/tensorflow-1.14.0-cp37-cp37m-macosx_10_7_x86_64.whl
42-
pip install psutil && \
42+
pip install psutil pip==19.3.1 && \
4343
pip install -U /usr/local/var/buildkite-agent/artifacts/$BUILDKITE_BUILD_ID/ngraph_tensorflow_bridge-*.whl
4444
4545
label: ":gear: Install"

test/ci/buildkite/ngtf-cpu_model-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
source /localdisk/buildkite/artifacts/$BUILDKITE_BUILD_ID/venv/bin/activate
2727
pip install psutil && pip install -U \
2828
/localdisk/buildkite/artifacts/$BUILDKITE_BUILD_ID/tensorflow/tensorflow-1.14.0-cp36-cp36m-linux_x86_64.whl
29+
pip install -U pip==19.3.1
2930
pip install -U /localdisk/buildkite/artifacts/$BUILDKITE_BUILD_ID/ngraph_tensorflow_bridge-*.whl
3031
3132
label: ":gear: Install"

0 commit comments

Comments
 (0)