-
Notifications
You must be signed in to change notification settings - Fork 15
Langjian/distributed json #366
Changes from 4 commits
3878e43
4decf57
cfb0a83
76ab3fa
289a43d
2163ac1
34c4ddf
2e70b97
1c34c3d
70449be
5ea9070
73cf9d0
2c594ee
d788247
0371935
d16f2d9
f205cb2
0ecd43b
100c129
dda11aa
6caf977
e2ba875
59ffb37
7f6c498
6507c3a
dbb302e
b163c5c
35af774
97bb170
7515794
2f515af
e97fd82
1f9f611
7922d0b
e8553cf
0499c73
361c725
4533c46
e2c3009
ae96c77
8a941ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,11 @@ | |
|
||
See extensive documentation at | ||
https://www.tensorflow.org/get_started/mnist/beginners | ||
Add distributed fetaure with horovod | ||
1. hvd.init() | ||
2. Add distributed wrapper from hvd.DistributedOptimizer | ||
3. Broadcast the variables from root rank to the rest processors: hvd.BroadcastGlobalVariablesHook(0) | ||
4. Print the output for root rank only | ||
""" | ||
from __future__ import absolute_import | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide a summary of modifications made to this file and a reference to the source of this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Listed the changes I made from the source file and added the link to the reference source of this file |
||
from __future__ import division | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ | |
#include "ngraph/runtime/interpreter/int_backend.hpp" | ||
|
||
#ifdef NGRAPH_DISTRIBUTED | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to |
||
#include <mpi.h> | ||
#include "ngraph/distributed.hpp" | ||
#endif | ||
|
||
using namespace std; | ||
|
@@ -267,13 +267,9 @@ class NGraphEncapsulateOp : public OpKernel { | |
std::string file_name = | ||
"tf_function_" + ctx->op_kernel().name() + ".json"; | ||
#ifdef NGRAPH_DISTRIBUTED | ||
int flag = 0; | ||
MPI_Initialized(&flag); | ||
if (!flag) { | ||
MPI_Init(NULL, NULL); | ||
} | ||
ngraph::Distributed dist; | ||
int Rank_ID; | ||
MPI_Comm_rank(MPI_COMM_WORLD, &Rank_ID); | ||
Rank_ID = dist->get_rank(); | ||
NgraphSerialize("tf_function_" + ctx->op_kernel().name() + "_" + | ||
to_string(Rank_ID) + ".json", | ||
ng_function); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
#include <iomanip> | ||
|
||
#ifdef NGRAPH_DISTRIBUTED | ||
#include <mpi.h> | ||
#include "ngraph/distributed.hpp" | ||
#endif | ||
|
||
using namespace std; | ||
|
@@ -107,13 +107,8 @@ class NGraphRewritePass : public GraphOptimizationPass { | |
std::stringstream ss; | ||
ss << kind << "_" << std::setfill('0') << std::setw(4) << idx; | ||
#ifdef NGRAPH_DISTRIBUTED | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider a function that can be used instead of the code repetition below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used the distributed class defined in nGraph core |
||
int flag = 0; | ||
MPI_Initialized(&flag); | ||
if (!flag) { | ||
MPI_Init(NULL, NULL); | ||
} | ||
int Rank_ID; | ||
MPI_Comm_rank(MPI_COMM_WORLD, &Rank_ID); | ||
ngraph::Distributed dist; | ||
int Rank_ID = dist->get_rank(); | ||
ss << "_" << std::setfill('0') << std::setw(4) << Rank_ID; | ||
#endif | ||
return ss.str(); | ||
|
@@ -124,13 +119,8 @@ class NGraphRewritePass : public GraphOptimizationPass { | |
ss << GraphFilenamePrefix(kind, idx) << "_" << std::setfill('0') | ||
<< std::setw(4) << sub_idx; | ||
#ifdef NGRAPH_DISTRIBUTED | ||
int flag = 0; | ||
MPI_Initialized(&flag); | ||
if (!flag) { | ||
MPI_Init(NULL, NULL); | ||
} | ||
int Rank_ID; | ||
MPI_Comm_rank(MPI_COMM_WORLD, &Rank_ID); | ||
ngraph::Distributed dist; | ||
int Rank_ID = dist->get_rank(); | ||
ss << "_" << std::setfill('0') << std::setw(4) << Rank_ID; | ||
#endif | ||
return ss.str(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this temporary? If not please remove the commented out code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed back to include the MPI build