aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Rohan Jain <rohanj@google.com>2017-10-02 14:58:39 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-10-02 15:05:25 -0700
commitdd94edb18cb7bf00156a4213bbdb77a3a79790d5 (patch)
tree73b235af9a97c7be2755e21f2b96f49a58ce08e4
parenta470779865883706dc2db1dcd8bd386527e1df03 (diff)
Standardizing device names to the newer /device:<type>:<index> format by making all the device factories produce the new device names.
The python API would still support the legacy /<type>:<index> format so the C++ layer would accept both legacy and standardized names but the C++ layer would produce only new device names now. PiperOrigin-RevId: 170758313
-rw-r--r--tensorflow/core/common_runtime/device_mgr.cc9
-rw-r--r--tensorflow/core/common_runtime/function_test.cc28
-rw-r--r--tensorflow/core/common_runtime/gpu/gpu_device_factory.cc2
-rw-r--r--tensorflow/core/common_runtime/graph_runner.cc9
-rw-r--r--tensorflow/core/common_runtime/process_function_library_runtime.cc14
-rw-r--r--tensorflow/core/common_runtime/process_function_library_runtime_test.cc12
-rw-r--r--tensorflow/core/common_runtime/threadpool_device_factory.cc2
-rw-r--r--tensorflow/core/distributed_runtime/cluster_function_library_runtime_test.cc16
-rw-r--r--tensorflow/core/kernels/function_ops.cc4
-rw-r--r--tensorflow/core/util/device_name_utils.cc42
-rw-r--r--tensorflow/core/util/device_name_utils.h16
-rw-r--r--tensorflow/core/util/device_name_utils_test.cc106
-rw-r--r--tensorflow/python/client/session_test.py3
-rw-r--r--tensorflow/python/client/timeline_test.py8
-rw-r--r--tensorflow/python/debug/cli/analyzer_cli_test.py4
-rw-r--r--tensorflow/python/debug/lib/session_debug_testlib.py2
-rw-r--r--tensorflow/python/kernel_tests/tensor_array_ops_test.py2
-rw-r--r--tensorflow/python/profiler/model_analyzer_test.py6
18 files changed, 184 insertions, 101 deletions
diff --git a/tensorflow/core/common_runtime/device_mgr.cc b/tensorflow/core/common_runtime/device_mgr.cc
index 0a4e0afc87..1f0cc5e83b 100644
--- a/tensorflow/core/common_runtime/device_mgr.cc
+++ b/tensorflow/core/common_runtime/device_mgr.cc
@@ -29,13 +29,16 @@ DeviceMgr::DeviceMgr(const std::vector<Device*>& devices)
for (Device* d : devices) {
devices_.push_back(d);
- // Register under the (1) full name, (2) canonical name, and (3) local name.
+ // Register under the (1) full name and (2) canonical name.
for (const string& name :
DeviceNameUtils::GetNamesForDeviceMappings(d->parsed_name())) {
device_map_[CopyToBackingStore(name)] = d;
}
- string lname = DeviceNameUtils::LocalName(d->name());
- device_map_[CopyToBackingStore(lname)] = d;
+ // Register under the (3) local name and (4) legacy local name.
+ for (const string& name :
+ DeviceNameUtils::GetLocalNamesForDeviceMappings(d->parsed_name())) {
+ device_map_[CopyToBackingStore(name)] = d;
+ }
device_type_counts_[d->device_type()]++;
}
}
diff --git a/tensorflow/core/common_runtime/function_test.cc b/tensorflow/core/common_runtime/function_test.cc
index 23d2741913..b77a8f50c4 100644
--- a/tensorflow/core/common_runtime/function_test.cc
+++ b/tensorflow/core/common_runtime/function_test.cc
@@ -499,7 +499,7 @@ TEST_F(FunctionLibraryRuntimeTest, OptimizeGraph) {
auto x = ops::_Arg(s.WithOpName("x"), DT_FLOAT, 0);
auto x4_x2_scale = ops::Const<float>(
s.WithOpName("x4/x2/scale/_12__cf__2")
- .WithDevice("/job:localhost/replica:0/task:0/cpu:0"),
+ .WithDevice("/job:localhost/replica:0/task:0/device:CPU:0"),
2.0f);
auto x4_x2_y = ops::Mul(s.WithOpName("x4/x2/y"), x, x4_x2_scale);
auto x4_y_y = ops::Mul(s.WithOpName("x4/y/y"), x4_x2_y, x4_x2_scale);
@@ -693,16 +693,16 @@ TEST_F(FunctionLibraryRuntimeTest, Gradient_XTimesTwo) {
Scope s = Scope::NewRootScope();
auto x = ops::_Arg(s.WithOpName("x"), DT_FLOAT, 0);
auto func0 = ops::_Arg(s.WithOpName("Func/_0"), DT_FLOAT, 1);
- auto scale =
- ops::Const(s.WithOpName("scale/_5__cf__6")
- .WithDevice("/job:localhost/replica:0/task:0/cpu:0"),
- 2.0f);
+ auto scale = ops::Const(
+ s.WithOpName("scale/_5__cf__6")
+ .WithDevice("/job:localhost/replica:0/task:0/device:CPU:0"),
+ 2.0f);
auto func1_gx = ops::Mul(s.WithOpName("Func/_1/gx"), func0, scale);
auto func1_sx = ops::Shape(s.WithOpName("Func/_1/sx"), x);
- auto const0 =
- ops::Const(s.WithOpName("Func/_1/sy/_6__cf__7")
- .WithDevice("/job:localhost/replica:0/task:0/cpu:0"),
- 0, {0});
+ auto const0 = ops::Const(
+ s.WithOpName("Func/_1/sy/_6__cf__7")
+ .WithDevice("/job:localhost/replica:0/task:0/device:CPU:0"),
+ 0, {0});
auto func1_rx = ops::internal::BroadcastGradientArgs(
s.WithOpName("Func/_1/rx"), func1_sx, const0);
auto func1_sum_gx =
@@ -950,14 +950,16 @@ TEST_F(FunctionLibraryRuntimeTest, CrossDevice) {
// Run on flr1_, flr2_ and make sure that the device it ran on was cpu:1.
TF_CHECK_OK(Run(flr1_, handle, opts, {}, {&y}));
test::ExpectTensorEqual<string>(
- y, test::AsTensor<string>({"/job:localhost/replica:0/task:0/cpu:1"},
- TensorShape({})));
+ y,
+ test::AsTensor<string>({"/job:localhost/replica:0/task:0/device:CPU:1"},
+ TensorShape({})));
opts.remote_execution = true;
opts.source_device = "/job:localhost/replica:0/task:0/cpu:2";
TF_CHECK_OK(Run(flr2_, handle, opts, {}, {&y}));
test::ExpectTensorEqual<string>(
- y, test::AsTensor<string>({"/job:localhost/replica:0/task:0/cpu:1"},
- TensorShape({})));
+ y,
+ test::AsTensor<string>({"/job:localhost/replica:0/task:0/device:CPU:1"},
+ TensorShape({})));
opts.rendezvous->Unref();
}
diff --git a/tensorflow/core/common_runtime/gpu/gpu_device_factory.cc b/tensorflow/core/common_runtime/gpu/gpu_device_factory.cc
index 1e7a2b35be..63ac3daba1 100644
--- a/tensorflow/core/common_runtime/gpu/gpu_device_factory.cc
+++ b/tensorflow/core/common_runtime/gpu/gpu_device_factory.cc
@@ -112,7 +112,7 @@ class GPUCompatibleCPUDeviceFactory : public DeviceFactory {
n = iter->second;
}
for (int i = 0; i < n; i++) {
- string name = strings::StrCat(name_prefix, "/cpu:", i);
+ string name = strings::StrCat(name_prefix, "/device:CPU:", i);
devices->push_back(new GPUCompatibleCPUDevice(
options, name, Bytes(256 << 20), DeviceLocality(), cpu_allocator()));
}
diff --git a/tensorflow/core/common_runtime/graph_runner.cc b/tensorflow/core/common_runtime/graph_runner.cc
index 2ce1e8b483..d0f9e6ed18 100644
--- a/tensorflow/core/common_runtime/graph_runner.cc
+++ b/tensorflow/core/common_runtime/graph_runner.cc
@@ -123,8 +123,8 @@ Status GraphRunner::Run(Graph* graph, FunctionLibraryRuntime* function_library,
for (const auto& in : inputs) {
const string& tensor_name = in.first;
input_names.emplace_back(tensor_name);
- string full_key = Rendezvous::CreateKey("/cpu:0", 1, "/cpu:1", tensor_name,
- FrameAndIter(0, 0));
+ string full_key = Rendezvous::CreateKey("/device:CPU:0", 1, "/device:CPU:1",
+ tensor_name, FrameAndIter(0, 0));
Rendezvous::ParsedKey parsed;
TF_RETURN_IF_ERROR(Rendezvous::ParseKey(full_key, &parsed));
TF_RETURN_IF_ERROR(rendez->Send(parsed, Rendezvous::Args(), in.second,
@@ -175,8 +175,9 @@ Status GraphRunner::Run(Graph* graph, FunctionLibraryRuntime* function_library,
outputs->resize(output_names.size());
for (size_t i = 0; i < output_names.size(); ++i) {
- const string& output_key = Rendezvous::CreateKey(
- "/cpu:0", 1, "/cpu:1", output_names[i], FrameAndIter(0, 0));
+ const string& output_key =
+ Rendezvous::CreateKey("/device:CPU:0", 1, "/device:CPU:1",
+ output_names[i], FrameAndIter(0, 0));
Rendezvous::ParsedKey parsed;
TF_RETURN_IF_ERROR(Rendezvous::ParseKey(output_key, &parsed));
bool is_dead;
diff --git a/tensorflow/core/common_runtime/process_function_library_runtime.cc b/tensorflow/core/common_runtime/process_function_library_runtime.cc
index ca7843ee67..68ff28e4d8 100644
--- a/tensorflow/core/common_runtime/process_function_library_runtime.cc
+++ b/tensorflow/core/common_runtime/process_function_library_runtime.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include "tensorflow/core/common_runtime/function.h"
#include "tensorflow/core/common_runtime/rendezvous_util.h"
#include "tensorflow/core/lib/gtl/map_util.h"
+#include "tensorflow/core/util/device_name_utils.h"
namespace tensorflow {
@@ -87,7 +88,7 @@ string ProcessFunctionLibraryRuntime::ObtainFunctionTarget(
if (!attrs.Find("_target", &value).ok()) {
return "";
}
- return value->s();
+ return DeviceNameUtils::CanonicalizeDeviceName(value->s());
}
/* static */
@@ -160,11 +161,17 @@ Status ProcessFunctionLibraryRuntime::GetDeviceContext(
FunctionLibraryRuntime* ProcessFunctionLibraryRuntime::GetFLR(
const string& device_name) {
- if (flr_map_.find(device_name) == flr_map_.end()) {
+ string clean_device_name;
+ if (device_name != kDefaultFLRDevice) {
+ clean_device_name = DeviceNameUtils::CanonicalizeDeviceName(device_name);
+ } else {
+ clean_device_name = device_name;
+ }
+ if (flr_map_.find(clean_device_name) == flr_map_.end()) {
LOG(ERROR) << "Could not find device: " << device_name;
return nullptr;
}
- return flr_map_[device_name].get();
+ return flr_map_[clean_device_name].get();
}
FunctionLibraryRuntime::Handle ProcessFunctionLibraryRuntime::AddHandle(
@@ -218,7 +225,6 @@ Status ProcessFunctionLibraryRuntime::Instantiate(
FunctionLibraryRuntime::Handle* handle) {
*handle = kInvalidHandle;
string target = ObtainFunctionTarget(attrs);
-
FunctionLibraryRuntime* flr = GetFLR(target);
if (flr != nullptr) {
return flr->Instantiate(function_name, attrs, handle);
diff --git a/tensorflow/core/common_runtime/process_function_library_runtime_test.cc b/tensorflow/core/common_runtime/process_function_library_runtime_test.cc
index b86a7f597e..cb416603be 100644
--- a/tensorflow/core/common_runtime/process_function_library_runtime_test.cc
+++ b/tensorflow/core/common_runtime/process_function_library_runtime_test.cc
@@ -118,7 +118,7 @@ TEST_F(ProcessFunctionLibraryRuntimeTest, ObtainFunctionTarget) {
AddAttr("_target", v, &attr_values);
AttrSlice attrs(&attr_values);
target = ProcessFunctionLibraryRuntime::ObtainFunctionTarget(attrs);
- EXPECT_EQ("/job:a/replica:0/task:0/cpu:1", target);
+ EXPECT_EQ("/job:a/replica:0/task:0/device:CPU:1", target);
}
TEST_F(ProcessFunctionLibraryRuntimeTest, GetDeviceIncarnation) {
@@ -160,7 +160,7 @@ TEST_F(ProcessFunctionLibraryRuntimeTest, SingleCallFindDevice) {
TF_CHECK_OK(Run("FindDevice", opts,
{{"_target", "/job:a/replica:0/task:0/cpu:0"}}, {}, {&y}));
test::ExpectTensorEqual<string>(
- y, test::AsTensor<string>({"/job:a/replica:0/task:0/cpu:0"},
+ y, test::AsTensor<string>({"/job:a/replica:0/task:0/device:CPU:0"},
TensorShape({})));
rendezvous_->Unref();
}
@@ -196,12 +196,12 @@ TEST_F(ProcessFunctionLibraryRuntimeTest, MultipleCallsSameDeviceFindDevice) {
TF_CHECK_OK(Run("FindDevice", opts,
{{"_target", "/job:a/replica:0/task:0/cpu:1"}}, {}, {&y}));
test::ExpectTensorEqual<string>(
- y, test::AsTensor<string>({"/job:a/replica:0/task:0/cpu:1"},
+ y, test::AsTensor<string>({"/job:a/replica:0/task:0/device:CPU:1"},
TensorShape({})));
TF_CHECK_OK(Run("FindDevice", opts,
{{"_target", "/job:a/replica:0/task:0/cpu:1"}}, {}, {&y}));
test::ExpectTensorEqual<string>(
- y, test::AsTensor<string>({"/job:a/replica:0/task:0/cpu:1"},
+ y, test::AsTensor<string>({"/job:a/replica:0/task:0/device:CPU:1"},
TensorShape({})));
rendezvous_->Unref();
}
@@ -216,12 +216,12 @@ TEST_F(ProcessFunctionLibraryRuntimeTest, MultipleCallsDiffDeviceFindDevice) {
TF_CHECK_OK(Run("FindDevice", opts,
{{"_target", "/job:a/replica:0/task:0/cpu:0"}}, {}, {&y}));
test::ExpectTensorEqual<string>(
- y, test::AsTensor<string>({"/job:a/replica:0/task:0/cpu:0"},
+ y, test::AsTensor<string>({"/job:a/replica:0/task:0/device:CPU:0"},
TensorShape({})));
TF_CHECK_OK(Run("FindDevice", opts,
{{"_target", "/job:a/replica:0/task:0/cpu:1"}}, {}, {&y}));
test::ExpectTensorEqual<string>(
- y, test::AsTensor<string>({"/job:a/replica:0/task:0/cpu:1"},
+ y, test::AsTensor<string>({"/job:a/replica:0/task:0/device:CPU:1"},
TensorShape({})));
rendezvous_->Unref();
}
diff --git a/tensorflow/core/common_runtime/threadpool_device_factory.cc b/tensorflow/core/common_runtime/threadpool_device_factory.cc
index 63e40fd82d..6a900c02c0 100644
--- a/tensorflow/core/common_runtime/threadpool_device_factory.cc
+++ b/tensorflow/core/common_runtime/threadpool_device_factory.cc
@@ -36,7 +36,7 @@ class ThreadPoolDeviceFactory : public DeviceFactory {
n = iter->second;
}
for (int i = 0; i < n; i++) {
- string name = strings::StrCat(name_prefix, "/cpu:", i);
+ string name = strings::StrCat(name_prefix, "/device:CPU:", i);
devices->push_back(new ThreadPoolDevice(
options, name, Bytes(256 << 20), DeviceLocality(), cpu_allocator()));
}
diff --git a/tensorflow/core/distributed_runtime/cluster_function_library_runtime_test.cc b/tensorflow/core/distributed_runtime/cluster_function_library_runtime_test.cc
index e8d5b0d97d..6855313b3b 100644
--- a/tensorflow/core/distributed_runtime/cluster_function_library_runtime_test.cc
+++ b/tensorflow/core/distributed_runtime/cluster_function_library_runtime_test.cc
@@ -112,7 +112,7 @@ TEST_F(ClusterFunctionLibraryRuntimeTest, ConstructFunctionGraph) {
node {
name: "_recv_x_0"
op: "_Recv"
- device: "/job:a/replica:0/task:0/cpu:0"
+ device: "/job:a/replica:0/task:0/device:CPU:0"
attr {
key: "client_terminated"
value {
@@ -122,13 +122,13 @@ node {
attr {
key: "recv_device"
value {
- s: "/job:a/replica:0/task:0/cpu:0"
+ s: "/job:a/replica:0/task:0/device:CPU:0"
}
}
attr {
key: "send_device"
value {
- s: "/job:a/replica:0/task:0/cpu:0"
+ s: "/job:a/replica:0/task:0/device:CPU:0"
}
}
attr {
@@ -154,7 +154,7 @@ node {
name: "XTimesTwo"
op: "XTimesTwo"
input: "_recv_x_0"
- device: "/job:a/replica:0/task:0/cpu:0"
+ device: "/job:a/replica:0/task:0/device:CPU:0"
attr {
key: "T"
value {
@@ -164,7 +164,7 @@ node {
attr {
key: "_target"
value {
- s: "/job:a/replica:0/task:0/cpu:0"
+ s: "/job:a/replica:0/task:0/device:CPU:0"
}
}
}
@@ -172,7 +172,7 @@ node {
name: "_send_y_0"
op: "_Send"
input: "XTimesTwo"
- device: "/job:a/replica:0/task:0/cpu:0"
+ device: "/job:a/replica:0/task:0/device:CPU:0"
attr {
key: "T"
value {
@@ -188,13 +188,13 @@ node {
attr {
key: "recv_device"
value {
- s: "/job:a/replica:0/task:0/cpu:0"
+ s: "/job:a/replica:0/task:0/device:CPU:0"
}
}
attr {
key: "send_device"
value {
- s: "/job:a/replica:0/task:0/cpu:0"
+ s: "/job:a/replica:0/task:0/device:CPU:0"
}
}
attr {
diff --git a/tensorflow/core/kernels/function_ops.cc b/tensorflow/core/kernels/function_ops.cc
index 584d41dfe0..1c6026c25d 100644
--- a/tensorflow/core/kernels/function_ops.cc
+++ b/tensorflow/core/kernels/function_ops.cc
@@ -28,6 +28,7 @@ limitations under the License.
#include "tensorflow/core/graph/gradients.h"
#include "tensorflow/core/graph/graph_constructor.h"
#include "tensorflow/core/platform/macros.h"
+#include "tensorflow/core/util/device_name_utils.h"
namespace tensorflow {
@@ -293,7 +294,8 @@ class RemoteCallOp : public AsyncOpKernel {
OP_REQUIRES_OK_ASYNC(ctx, ctx->input("target", &target), done);
AttrValueMap attr_values = func_.attr();
AttrValue v;
- const string& target_device = target->scalar<string>()();
+ const string& target_device =
+ DeviceNameUtils::CanonicalizeDeviceName(target->scalar<string>()());
v.set_s(target_device);
AddAttr("_target", v, &attr_values);
diff --git a/tensorflow/core/util/device_name_utils.cc b/tensorflow/core/util/device_name_utils.cc
index e667791c89..2d797c855a 100644
--- a/tensorflow/core/util/device_name_utils.cc
+++ b/tensorflow/core/util/device_name_utils.cc
@@ -104,11 +104,12 @@ string DeviceNameUtils::FullName(const string& job, int replica, int task,
return DeviceName(job, replica, task, "/device:", type, id);
}
-/* static */
-string DeviceNameUtils::LegacyName(const string& job, int replica, int task,
- const string& type, int id) {
+namespace {
+string LegacyName(const string& job, int replica, int task, const string& type,
+ int id) {
return DeviceName(job, replica, task, "/", str_util::Lowercase(type), id);
}
+} // anonymous namespace
bool DeviceNameUtils::ParseFullName(StringPiece fullname, ParsedName* p) {
p->Clear();
@@ -185,6 +186,18 @@ bool DeviceNameUtils::ParseFullName(StringPiece fullname, ParsedName* p) {
}
/* static */
+string DeviceNameUtils::CanonicalizeDeviceName(StringPiece fullname) {
+ ParsedName parsed_name;
+ if (ParseLocalName(fullname, &parsed_name)) {
+ return ParsedNameToString(parsed_name);
+ }
+ if (ParseFullName(fullname, &parsed_name)) {
+ return ParsedNameToString(parsed_name);
+ }
+ return "";
+}
+
+/* static */
string DeviceNameUtils::ParsedNameToString(const ParsedName& pn) {
string buf;
if (pn.has_job) strings::StrAppend(&buf, "/job:", pn.job);
@@ -338,8 +351,16 @@ bool DeviceNameUtils::IsSameAddressSpace(StringPiece src, StringPiece dst) {
/* static */
string DeviceNameUtils::LocalName(StringPiece type, int id) {
+ return strings::StrCat("/device:", type, ":", id);
+}
+
+namespace {
+// Returns the legacy local device name given its "type" and "id" (which is
+// '/device:type:id').
+string LegacyLocalName(StringPiece type, int id) {
return strings::StrCat(type, ":", id);
}
+} // anonymous namespace
/* static */
string DeviceNameUtils::LocalName(StringPiece fullname) {
@@ -353,12 +374,14 @@ bool DeviceNameUtils::ParseLocalName(StringPiece name, ParsedName* p) {
if (!ConsumeDeviceType(&name, &p->type)) {
return false;
}
+ p->has_type = true;
if (!str_util::ConsumePrefix(&name, ":")) {
return false;
}
if (!ConsumeNumber(&name, &p->id)) {
return false;
}
+ p->has_id = true;
return name.empty();
}
@@ -393,8 +416,17 @@ std::vector<string> DeviceNameUtils::GetNamesForDeviceMappings(
if (pn.has_job && pn.has_replica && pn.has_task && pn.has_type && pn.has_id) {
return {
DeviceNameUtils::FullName(pn.job, pn.replica, pn.task, pn.type, pn.id),
- DeviceNameUtils::LegacyName(pn.job, pn.replica, pn.task, pn.type,
- pn.id)};
+ LegacyName(pn.job, pn.replica, pn.task, pn.type, pn.id)};
+ } else {
+ return {};
+ }
+}
+
+std::vector<string> DeviceNameUtils::GetLocalNamesForDeviceMappings(
+ const ParsedName& pn) {
+ if (pn.has_type && pn.has_id) {
+ return {DeviceNameUtils::LocalName(pn.type, pn.id),
+ LegacyLocalName(pn.type, pn.id)};
} else {
return {};
}
diff --git a/tensorflow/core/util/device_name_utils.h b/tensorflow/core/util/device_name_utils.h
index 740aa13fa7..0ae28df997 100644
--- a/tensorflow/core/util/device_name_utils.h
+++ b/tensorflow/core/util/device_name_utils.h
@@ -48,9 +48,6 @@ class DeviceNameUtils {
// Returns a fully qualified device name given the parameters.
static string FullName(const string& job, int replica, int task,
const string& type, int id);
- // Returns a fully qualified device name given the parameters in legacy style.
- static string LegacyName(const string& job, int replica, int task,
- const string& type, int id);
struct ParsedName {
void Clear() {
@@ -91,6 +88,11 @@ class DeviceNameUtils {
// Parses "fullname" into "*parsed". Returns true iff succeeds.
static bool ParseFullName(StringPiece fullname, ParsedName* parsed);
+ // Canonicalizes "fullname". Accepts both legacy, newer and local versions of
+ // the device spec. Returns the newer version of the device spec. If we were
+ // unable to interpret / parse "fullname" returns "".
+ static string CanonicalizeDeviceName(StringPiece fullname);
+
// Returns true if "name" specifies any non-trivial constraint on the device.
static bool HasSomeDetails(const ParsedName& name) {
return name.has_job || name.has_replica || name.has_task || name.has_type ||
@@ -155,8 +157,14 @@ class DeviceNameUtils {
// Returns canonical and legacy full names for the given parsed
// device name 'pn'. The returned string names are often useful to
- // lookup devices from a mapping.
+ // look up devices from a mapping.
static std::vector<string> GetNamesForDeviceMappings(const ParsedName& pn);
+
+ // Returns canonical and legacy local names for the given parsed device name
+ // 'pn'. The returned string names are often useful to look up devices from a
+ // mapping.
+ static std::vector<string> GetLocalNamesForDeviceMappings(
+ const ParsedName& pn);
};
} // namespace tensorflow
diff --git a/tensorflow/core/util/device_name_utils_test.cc b/tensorflow/core/util/device_name_utils_test.cc
index 9a3f8849a6..c1bc0f3378 100644
--- a/tensorflow/core/util/device_name_utils_test.cc
+++ b/tensorflow/core/util/device_name_utils_test.cc
@@ -69,28 +69,25 @@ TEST(DeviceNameUtilsTest, Basic) {
EXPECT_EQ(DeviceNameUtils::FullName("hello", 1, 2, "CPU", 3),
"/job:hello/replica:1/task:2/device:CPU:3");
- EXPECT_EQ(DeviceNameUtils::LegacyName("hello", 1, 2, "CPU", 3),
- "/job:hello/replica:1/task:2/cpu:3");
-
{
DeviceNameUtils::ParsedName p;
EXPECT_FALSE(DeviceNameUtils::ParseFullName("foobar", &p));
- EXPECT_FALSE(
- DeviceNameUtils::ParseFullName("/job:123/replica:1/task:2/device:GPU:3", &p));
+ EXPECT_FALSE(DeviceNameUtils::ParseFullName(
+ "/job:123/replica:1/task:2/device:GPU:3", &p));
EXPECT_FALSE(
DeviceNameUtils::ParseFullName("/job:123/replica:1/task:2/gpu:", &p));
EXPECT_FALSE(DeviceNameUtils::ParseFullName(
"/job:123/replica:1/task:2/device:gpu:", &p));
- EXPECT_FALSE(
- DeviceNameUtils::ParseFullName("/job:foo/replica:-1/task:2/device:GPU:3", &p));
- EXPECT_FALSE(
- DeviceNameUtils::ParseFullName("/job:foo/replica:1/task:-2/device:GPU:3", &p));
+ EXPECT_FALSE(DeviceNameUtils::ParseFullName(
+ "/job:foo/replica:-1/task:2/device:GPU:3", &p));
+ EXPECT_FALSE(DeviceNameUtils::ParseFullName(
+ "/job:foo/replica:1/task:-2/device:GPU:3", &p));
EXPECT_FALSE(
DeviceNameUtils::ParseFullName("/job:foo/replica:1/task:2/bar:3", &p));
EXPECT_FALSE(DeviceNameUtils::ParseFullName(
"/job:foo/replica:1/task:2/device:GPU:3/extra", &p));
- EXPECT_TRUE(
- DeviceNameUtils::ParseFullName("/job:foo/replica:1/task:2/device:GPU:3", &p));
+ EXPECT_TRUE(DeviceNameUtils::ParseFullName(
+ "/job:foo/replica:1/task:2/device:GPU:3", &p));
EXPECT_TRUE(p.has_job);
EXPECT_TRUE(p.has_replica);
EXPECT_TRUE(p.has_task);
@@ -193,7 +190,8 @@ TEST(DeviceNameUtilsTest, Basic) {
}
{
DeviceNameUtils::ParsedName p;
- EXPECT_TRUE(DeviceNameUtils::ParseFullName("/job:*/replica:4/device:GPU:5", &p));
+ EXPECT_TRUE(
+ DeviceNameUtils::ParseFullName("/job:*/replica:4/device:GPU:5", &p));
EXPECT_FALSE(p.has_job);
EXPECT_TRUE(p.has_replica);
EXPECT_FALSE(p.has_task);
@@ -216,29 +214,33 @@ TEST(DeviceNameUtilsTest, Basic) {
}
EXPECT_TRUE(DeviceNameUtils::IsSameAddressSpace(
- "/job:foo/replica:1/task:2/cpu:3", "/job:foo/replica:1/task:2/device:GPU:4"));
+ "/job:foo/replica:1/task:2/cpu:3",
+ "/job:foo/replica:1/task:2/device:GPU:4"));
EXPECT_FALSE(DeviceNameUtils::IsSameAddressSpace(
- "/job:foo/replica:1/task:2/cpu:3", "/job:foo/replica:1/task:3/device:GPU:4"));
+ "/job:foo/replica:1/task:2/cpu:3",
+ "/job:foo/replica:1/task:3/device:GPU:4"));
EXPECT_FALSE(DeviceNameUtils::IsSameAddressSpace(
- "/job:foo/replica:1/task:2/cpu:3", "/job:foo/replica:10/task:2/device:GPU:4"));
+ "/job:foo/replica:1/task:2/cpu:3",
+ "/job:foo/replica:10/task:2/device:GPU:4"));
EXPECT_FALSE(DeviceNameUtils::IsSameAddressSpace(
- "/job:foo/replica:1/task:2/cpu:3", "/job:bar/replica:1/task:2/device:GPU:4"));
+ "/job:foo/replica:1/task:2/cpu:3",
+ "/job:bar/replica:1/task:2/device:GPU:4"));
- EXPECT_EQ(DeviceNameUtils::LocalName("CPU", 1), "CPU:1");
- EXPECT_EQ(DeviceNameUtils::LocalName("GPU", 2), "GPU:2");
+ EXPECT_EQ(DeviceNameUtils::LocalName("CPU", 1), "/device:CPU:1");
+ EXPECT_EQ(DeviceNameUtils::LocalName("GPU", 2), "/device:GPU:2");
EXPECT_EQ(DeviceNameUtils::LocalName("MySpecialDevice", 13),
- "MySpecialDevice:13");
+ "/device:MySpecialDevice:13");
EXPECT_EQ(
DeviceNameUtils::LocalName("/job:foo/replica:1/task:2/device:CPU:3"),
- "CPU:3");
+ "/device:CPU:3");
EXPECT_EQ(DeviceNameUtils::LocalName("/job:foo/replica:1/task:2/cpu:3"),
- "CPU:3");
+ "/device:CPU:3");
EXPECT_EQ(
DeviceNameUtils::LocalName("/job:foo/replica:1/task:2/device:abc:73"),
- "abc:73");
+ "/device:abc:73");
{
DeviceNameUtils::ParsedName p;
@@ -285,16 +287,20 @@ static bool IsCSHelper(StringPiece pattern, StringPiece actual) {
TEST(DeviceNameUtilsTest, IsCompleteSpecification) {
EXPECT_TRUE(IsCSHelper("/job:*", "/job:work/replica:1/task:2/device:GPU:3"));
+ EXPECT_TRUE(IsCSHelper("/job:*/replica:*",
+ "/job:work/replica:1/task:2/device:GPU:3"));
EXPECT_TRUE(
- IsCSHelper("/job:*/replica:*", "/job:work/replica:1/task:2/device:GPU:3"));
- EXPECT_TRUE(IsCSHelper("/job:*/task:*", "/job:work/replica:1/task:2/device:GPU:3"));
+ IsCSHelper("/job:*/task:*", "/job:work/replica:1/task:2/device:GPU:3"));
EXPECT_TRUE(IsCSHelper("/job:*/replica:*/task:*",
"/job:work/replica:1/task:2/device:GPU:3"));
+ EXPECT_TRUE(IsCSHelper("/job:*/replica:*/gpu:*",
+ "/job:work/replica:1/task:2/device:GPU:3"));
+ EXPECT_FALSE(
+ IsCSHelper("/cpu:*", "/job:worker/replica:1/task:2/device:GPU:3"));
+ EXPECT_FALSE(
+ IsCSHelper("/device:GPU:2", "/job:worker/replica:1/task:2/device:GPU:1"));
EXPECT_TRUE(
- IsCSHelper("/job:*/replica:*/gpu:*", "/job:work/replica:1/task:2/device:GPU:3"));
- EXPECT_FALSE(IsCSHelper("/cpu:*", "/job:worker/replica:1/task:2/device:GPU:3"));
- EXPECT_FALSE(IsCSHelper("/device:GPU:2", "/job:worker/replica:1/task:2/device:GPU:1"));
- EXPECT_TRUE(IsCSHelper("/gpu:*", "/job:worker/replica:1/task:2/device:GPU:3"));
+ IsCSHelper("/gpu:*", "/job:worker/replica:1/task:2/device:GPU:3"));
}
static bool IsSpecHelper(StringPiece pattern, StringPiece actual) {
@@ -305,13 +311,14 @@ static bool IsSpecHelper(StringPiece pattern, StringPiece actual) {
}
TEST(DeviceNameUtilsTest, IsSpecification) {
- EXPECT_TRUE(IsSpecHelper("/job:*", "/job:work/replica:1/task:2/device:GPU:3"));
+ EXPECT_TRUE(
+ IsSpecHelper("/job:*", "/job:work/replica:1/task:2/device:GPU:3"));
EXPECT_TRUE(IsSpecHelper("/job:*", "/job:work/replica:1/device:GPU:3"));
EXPECT_TRUE(IsSpecHelper("/job:*", "/job:work/replica:1"));
EXPECT_TRUE(IsSpecHelper("/job:*", "/replica:1"));
EXPECT_TRUE(IsSpecHelper("/job:*", "/job:work"));
- EXPECT_TRUE(
- IsSpecHelper("/job:*/replica:*", "/job:work/replica:1/task:2/device:GPU:3"));
+ EXPECT_TRUE(IsSpecHelper("/job:*/replica:*",
+ "/job:work/replica:1/task:2/device:GPU:3"));
EXPECT_TRUE(IsSpecHelper("/job:work/replica:1/gpu:*",
"/job:work/replica:1/task:2/device:GPU:3"));
EXPECT_TRUE(IsSpecHelper("/job:work/replica:1/device:GPU:3",
@@ -324,13 +331,17 @@ TEST(DeviceNameUtilsTest, IsSpecification) {
EXPECT_TRUE(IsSpecHelper("/task:2", "/job:*/replica:1/task:2/device:GPU:3"));
EXPECT_TRUE(IsSpecHelper("/cpu:*", "/job:*/replica:1/task:2/cpu:1"));
EXPECT_TRUE(IsSpecHelper("/cpu:0", "/cpu:0"));
- EXPECT_TRUE(IsSpecHelper("/gpu:*", "/job:worker/replica:1/task:2/device:GPU:3"));
+ EXPECT_TRUE(
+ IsSpecHelper("/gpu:*", "/job:worker/replica:1/task:2/device:GPU:3"));
- EXPECT_FALSE(IsSpecHelper("/job:worker/replica:1/task:2/device:GPU:3", "/gpu:*"));
+ EXPECT_FALSE(
+ IsSpecHelper("/job:worker/replica:1/task:2/device:GPU:3", "/gpu:*"));
EXPECT_FALSE(IsSpecHelper("/cpu:*", "/job:*/replica:1/task:2"));
EXPECT_FALSE(IsSpecHelper("/cpu:*", "/job:*/replica:1/task:2/device:GPU:1"));
- EXPECT_FALSE(IsSpecHelper("/cpu:*", "/job:worker/replica:1/task:2/device:GPU:3"));
- EXPECT_FALSE(IsSpecHelper("/device:GPU:2", "/job:worker/replica:1/task:2/device:GPU:1"));
+ EXPECT_FALSE(
+ IsSpecHelper("/cpu:*", "/job:worker/replica:1/task:2/device:GPU:3"));
+ EXPECT_FALSE(IsSpecHelper("/device:GPU:2",
+ "/job:worker/replica:1/task:2/device:GPU:1"));
EXPECT_FALSE(IsSpecHelper("/job:work/replica:*/task:0",
"/job:work/replica:1/task:2/device:GPU:3"));
EXPECT_FALSE(IsSpecHelper("/job:work/replica:0/task:2",
@@ -348,7 +359,8 @@ TEST(DeviceNameUtilsTest, SplitDeviceName) {
"/job:foo/cpu:1/task:2/replica:1", &task, &device));
EXPECT_EQ("/job:foo/replica:1/task:2", task);
EXPECT_EQ("CPU:1", device);
- EXPECT_TRUE(DeviceNameUtils::SplitDeviceName("/device:GPU:3", &task, &device));
+ EXPECT_TRUE(
+ DeviceNameUtils::SplitDeviceName("/device:GPU:3", &task, &device));
EXPECT_EQ("", task);
EXPECT_EQ("GPU:3", device);
EXPECT_FALSE(DeviceNameUtils::SplitDeviceName("gpu:3", &task, &device));
@@ -440,11 +452,12 @@ TEST(DeviceNameUtilsTest, MergeDevNamesAllowSoftPlacement) {
// Incompatible components with allow_soft_placement.
MergeDevNamesHelperAllowSoftPlacement("/gpu:*", "/cpu:1", "");
MergeDevNamesHelperAllowSoftPlacement("/cpu:*", "/device:GPU:1", "");
- MergeDevNamesHelperAllowSoftPlacement("/device:GPU:1", "/device:GPU:2", "/device:GPU:*");
+ MergeDevNamesHelperAllowSoftPlacement("/device:GPU:1", "/device:GPU:2",
+ "/device:GPU:*");
}
-
TEST(DeviceNameUtilsTest, GetNamesForDeviceMappings) {
- DeviceNameUtils::ParsedName p = Name("/job:foo/replica:10/task:0/device:GPU:1");
+ DeviceNameUtils::ParsedName p =
+ Name("/job:foo/replica:10/task:0/device:GPU:1");
EXPECT_EQ(str_util::Join(DeviceNameUtils::GetNamesForDeviceMappings(p), ","),
"/job:foo/replica:10/task:0/device:GPU:1,"
"/job:foo/replica:10/task:0/gpu:1");
@@ -453,6 +466,21 @@ TEST(DeviceNameUtilsTest, GetNamesForDeviceMappings) {
"");
}
+TEST(DeviceNameUtilsTest, CanonicalizeDeviceName) {
+ EXPECT_EQ("/job:foo/replica:10/task:0/device:CPU:1",
+ DeviceNameUtils::CanonicalizeDeviceName(
+ "/job:foo/replica:10/task:0/device:CPU:1"));
+ EXPECT_EQ("/job:foo/replica:10/task:0/device:CPU:1",
+ DeviceNameUtils::CanonicalizeDeviceName(
+ "/job:foo/task:0/replica:10/device:CPU:1"));
+ EXPECT_EQ("/job:foo/replica:10/task:0/device:CPU:1",
+ DeviceNameUtils::CanonicalizeDeviceName(
+ "/job:foo/task:0/replica:10/cpu:1"));
+ EXPECT_EQ("/device:CPU:0", DeviceNameUtils::CanonicalizeDeviceName("CPU:0"));
+ EXPECT_EQ("", DeviceNameUtils::CanonicalizeDeviceName(
+ "/job:foo/task:0/replica/cpu:1"));
+}
+
static void BM_ParseFullName(int iters) {
DeviceNameUtils::ParsedName p;
while (iters--) {
diff --git a/tensorflow/python/client/session_test.py b/tensorflow/python/client/session_test.py
index 32c738f0f1..6b45a5f313 100644
--- a/tensorflow/python/client/session_test.py
+++ b/tensorflow/python/client/session_test.py
@@ -1656,7 +1656,8 @@ class SessionTest(test_util.TensorFlowTestCase):
with CaptureStderr() as log:
sess.run(c)
# Ensure that we did log device placement.
- self.assertTrue('/job:local/replica:0/task:0/cpu:0' in str(log), str(log))
+ self.assertTrue('/job:local/replica:0/task:0/device:CPU:0' in str(log),
+ str(log))
def testLocalMasterSessionTimeout(self):
# Test that the timeout passed in a config to the session works correctly.
diff --git a/tensorflow/python/client/timeline_test.py b/tensorflow/python/client/timeline_test.py
index 8396df5f40..9641b8b7f2 100644
--- a/tensorflow/python/client/timeline_test.py
+++ b/tensorflow/python/client/timeline_test.py
@@ -69,7 +69,7 @@ class TimelineTest(test.TestCase):
self.assertTrue(run_metadata.HasField('step_stats'))
step_stats = run_metadata.step_stats
devices = [d.device for d in step_stats.dev_stats]
- self.assertTrue('/job:localhost/replica:0/task:0/cpu:0' in devices)
+ self.assertTrue('/job:localhost/replica:0/task:0/device:CPU:0' in devices)
tl = timeline.Timeline(step_stats)
ctf = tl.generate_chrome_trace_format()
self._validateTrace(ctf)
@@ -181,9 +181,9 @@ class TimelineTest(test.TestCase):
self.assertTrue(run_metadata.HasField('step_stats'))
step_stats = run_metadata.step_stats
devices = [d.device for d in step_stats.dev_stats]
- self.assertTrue('/job:localhost/replica:0/task:0/cpu:0' in devices)
- self.assertTrue('/job:localhost/replica:0/task:0/cpu:1' in devices)
- self.assertTrue('/job:localhost/replica:0/task:0/cpu:2' in devices)
+ self.assertTrue('/job:localhost/replica:0/task:0/device:CPU:0' in devices)
+ self.assertTrue('/job:localhost/replica:0/task:0/device:CPU:1' in devices)
+ self.assertTrue('/job:localhost/replica:0/task:0/device:CPU:2' in devices)
tl = timeline.Timeline(step_stats)
ctf = tl.generate_chrome_trace_format()
self._validateTrace(ctf)
diff --git a/tensorflow/python/debug/cli/analyzer_cli_test.py b/tensorflow/python/debug/cli/analyzer_cli_test.py
index e848fd1f4e..8fcdcc777e 100644
--- a/tensorflow/python/debug/cli/analyzer_cli_test.py
+++ b/tensorflow/python/debug/cli/analyzer_cli_test.py
@@ -574,7 +574,7 @@ class AnalyzerCLISimpleMulAddTest(test_util.TensorFlowTestCase):
gpu_name = test_util.gpu_device_name()
cls._main_device = "/job:localhost/replica:0/task:0" + gpu_name
else:
- cls._main_device = "/job:localhost/replica:0/task:0/cpu:0"
+ cls._main_device = "/job:localhost/replica:0/task:0/device:CPU:0"
cls._curr_file_path = os.path.abspath(
tf_inspect.getfile(tf_inspect.currentframe()))
@@ -1595,7 +1595,7 @@ class AnalyzerCLIControlDepTest(test_util.TensorFlowTestCase):
gpu_name = test_util.gpu_device_name()
cls._main_device = "/job:localhost/replica:0/task:0" + gpu_name
else:
- cls._main_device = "/job:localhost/replica:0/task:0/cpu:0"
+ cls._main_device = "/job:localhost/replica:0/task:0/device:CPU:0"
with session.Session(config=no_rewrite_session_config()) as sess:
x_init_val = np.array([5.0, 3.0])
diff --git a/tensorflow/python/debug/lib/session_debug_testlib.py b/tensorflow/python/debug/lib/session_debug_testlib.py
index d4b9d06b54..3b9a5d07c2 100644
--- a/tensorflow/python/debug/lib/session_debug_testlib.py
+++ b/tensorflow/python/debug/lib/session_debug_testlib.py
@@ -95,7 +95,7 @@ class SessionDebugTestBase(test_util.TensorFlowTestCase):
else:
cls._expected_partition_graph_count = 1
cls._expected_num_devices = 1
- cls._main_device = "/job:localhost/replica:0/task:0/cpu:0"
+ cls._main_device = "/job:localhost/replica:0/task:0/device:CPU:0"
@classmethod
def tearDownClass(cls):
diff --git a/tensorflow/python/kernel_tests/tensor_array_ops_test.py b/tensorflow/python/kernel_tests/tensor_array_ops_test.py
index 9941c97c30..cffedf63f7 100644
--- a/tensorflow/python/kernel_tests/tensor_array_ops_test.py
+++ b/tensorflow/python/kernel_tests/tensor_array_ops_test.py
@@ -1305,7 +1305,7 @@ class TensorArrayTest(test.TestCase):
dev_stats = {d.device: list(d.node_stats)
for d in run_metadata.step_stats.dev_stats}
for d in dev_stats:
- if "/task:0/" in d and "cpu" in d: # Skip any GPU node stats
+ if "/task:0/" in d and "CPU" in d: # Skip any GPU node stats
self.assertTrue(
[s for s in dev_stats[d] if "/TensorArray" in s.node_name])
else:
diff --git a/tensorflow/python/profiler/model_analyzer_test.py b/tensorflow/python/profiler/model_analyzer_test.py
index 81c628289e..943ae0a3a1 100644
--- a/tensorflow/python/profiler/model_analyzer_test.py
+++ b/tensorflow/python/profiler/model_analyzer_test.py
@@ -62,7 +62,7 @@ class PrintModelAnalysisTest(test.TestCase):
def testSelectEverthingDetail(self):
ops.reset_default_graph()
- dev = '/gpu:0' if test.is_gpu_available() else '/cpu:0'
+ dev = '/device:GPU:0' if test.is_gpu_available() else '/device:CPU:0'
outfile = os.path.join(test.get_temp_dir(), 'dump')
opts = (builder(builder.trainable_variables_parameter())
.with_file_output(outfile)
@@ -143,7 +143,7 @@ class PrintModelAnalysisTest(test.TestCase):
disable_model_pruning=True)
graph_options = config_pb2.GraphOptions(rewrite_options=rewriter_config)
config = config_pb2.ConfigProto(graph_options=graph_options)
- with session.Session(config=config) as sess, ops.device('/cpu:0'):
+ with session.Session(config=config) as sess, ops.device('/device:CPU:0'):
x = lib.BuildSmallModel()
sess.run(variables.global_variables_initializer())
@@ -159,7 +159,7 @@ class PrintModelAnalysisTest(test.TestCase):
with gfile.Open(outfile, 'r') as f:
# pylint: disable=line-too-long
self.assertEqual(
- 'node name | # parameters | # float_ops | assigned devices | op types | op count (run|defined) | input shapes\n_TFProfRoot (--/451 params, --/11.34k flops, _kTFScopeParent, --/8|--/36, )\n Conv2D (0/0 params, 5.83k/5.83k flops, /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/cpu:0|Conv2D, 1/1|1/1, 0:2x6x6x3|1:3x3x3x6)\n Conv2D_1 (0/0 params, 4.61k/4.61k flops, /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/cpu:0|Conv2D, 1/1|1/1, 0:2x3x3x6|1:2x2x6x12)\n DW (3x3x3x6, 162/162 params, 0/324 flops, /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/cpu:0|VariableV2|_trainable_variables, 1/2|1/10, )\n DW/Assign (0/0 params, 0/0 flops, Assign, 0/0|1/1, 0:3x3x3x6|1:3x3x3x6)\n DW/Initializer (0/0 params, 0/324 flops, _kTFScopeParent, 0/0|1/7, )\n DW/Initializer/random_normal (0/0 params, 162/324 flops, Add, 0/0|1/6, 0:3x3x3x6|1:1)\n DW/Initializer/random_normal/RandomStandardNormal (0/0 params, 0/0 flops, RandomStandardNormal, 0/0|1/1, 0:4)\n DW/Initializer/random_normal/mean (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW/Initializer/random_normal/mul (0/0 params, 162/162 flops, Mul, 0/0|1/1, 0:3x3x3x6|1:1)\n DW/Initializer/random_normal/shape (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW/Initializer/random_normal/stddev (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW/read (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/cpu:0|Identity, 1/1|1/1, 0:3x3x3x6)\n DW2 (2x2x6x12, 288/288 params, 0/576 flops, /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/cpu:0|VariableV2|_trainable_variables, 1/2|1/10, )\n DW2/Assign (0/0 params, 0/0 flops, Assign, 0/0|1/1, 0:2x2x6x12|1:2x2x6x12)\n DW2/Initializer (0/0 params, 0/576 flops, _kTFScopeParent, 0/0|1/7, )\n DW2/Initializer/random_normal (0/0 params, 288/576 flops, Add, 0/0|1/6, 0:2x2x6x12|1:1)\n DW2/Initializer/random_normal/RandomStandardNormal (0/0 params, 0/0 flops, RandomStandardNormal, 0/0|1/1, 0:4)\n DW2/Initializer/random_normal/mean (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW2/Initializer/random_normal/mul (0/0 params, 288/288 flops, Mul, 0/0|1/1, 0:2x2x6x12|1:1)\n DW2/Initializer/random_normal/shape (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW2/Initializer/random_normal/stddev (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW2/read (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/cpu:0|Identity, 1/1|1/1, 0:2x2x6x12)\n ScalarW (1, 1/1 params, 0/2 flops, VariableV2|_trainable_variables, 0/0|1/10, )\n ScalarW/Assign (0/0 params, 0/0 flops, Assign, 0/0|1/1, 0:1|1:1)\n ScalarW/Initializer (0/0 params, 0/2 flops, _kTFScopeParent, 0/0|1/7, )\n ScalarW/Initializer/random_normal (0/0 params, 1/2 flops, Add, 0/0|1/6, 0:1|1:1)\n ScalarW/Initializer/random_normal/RandomStandardNormal (0/0 params, 0/0 flops, RandomStandardNormal, 0/0|1/1, 0:0)\n ScalarW/Initializer/random_normal/mean (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n ScalarW/Initializer/random_normal/mul (0/0 params, 1/1 flops, Mul, 0/0|1/1, 0:1|1:1)\n ScalarW/Initializer/random_normal/shape (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n ScalarW/Initializer/random_normal/stddev (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n ScalarW/read (0/0 params, 0/0 flops, Identity, 0/0|1/1, 0:1)\n _retval_Conv2D_1_0_0 (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/cpu:0|RunTimeOp, 1/1|1/1, )\n init (0/0 params, 0/0 flops, NoOp, 0/0|1/1, 0:1|1:3x3x3x6|2:2x2x6x12)\n zeros (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/cpu:0|Const, 1/1|1/1, )\n',
+ 'node name | # parameters | # float_ops | assigned devices | op types | op count (run|defined) | input shapes\n_TFProfRoot (--/451 params, --/11.34k flops, _kTFScopeParent, --/8|--/36, )\n Conv2D (0/0 params, 5.83k/5.83k flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Conv2D, 1/1|1/1, 0:2x6x6x3|1:3x3x3x6)\n Conv2D_1 (0/0 params, 4.61k/4.61k flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Conv2D, 1/1|1/1, 0:2x3x3x6|1:2x2x6x12)\n DW (3x3x3x6, 162/162 params, 0/324 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|VariableV2|_trainable_variables, 1/2|1/10, )\n DW/Assign (0/0 params, 0/0 flops, Assign, 0/0|1/1, 0:3x3x3x6|1:3x3x3x6)\n DW/Initializer (0/0 params, 0/324 flops, _kTFScopeParent, 0/0|1/7, )\n DW/Initializer/random_normal (0/0 params, 162/324 flops, Add, 0/0|1/6, 0:3x3x3x6|1:1)\n DW/Initializer/random_normal/RandomStandardNormal (0/0 params, 0/0 flops, RandomStandardNormal, 0/0|1/1, 0:4)\n DW/Initializer/random_normal/mean (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW/Initializer/random_normal/mul (0/0 params, 162/162 flops, Mul, 0/0|1/1, 0:3x3x3x6|1:1)\n DW/Initializer/random_normal/shape (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW/Initializer/random_normal/stddev (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW/read (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Identity, 1/1|1/1, 0:3x3x3x6)\n DW2 (2x2x6x12, 288/288 params, 0/576 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|VariableV2|_trainable_variables, 1/2|1/10, )\n DW2/Assign (0/0 params, 0/0 flops, Assign, 0/0|1/1, 0:2x2x6x12|1:2x2x6x12)\n DW2/Initializer (0/0 params, 0/576 flops, _kTFScopeParent, 0/0|1/7, )\n DW2/Initializer/random_normal (0/0 params, 288/576 flops, Add, 0/0|1/6, 0:2x2x6x12|1:1)\n DW2/Initializer/random_normal/RandomStandardNormal (0/0 params, 0/0 flops, RandomStandardNormal, 0/0|1/1, 0:4)\n DW2/Initializer/random_normal/mean (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW2/Initializer/random_normal/mul (0/0 params, 288/288 flops, Mul, 0/0|1/1, 0:2x2x6x12|1:1)\n DW2/Initializer/random_normal/shape (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW2/Initializer/random_normal/stddev (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW2/read (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Identity, 1/1|1/1, 0:2x2x6x12)\n ScalarW (1, 1/1 params, 0/2 flops, VariableV2|_trainable_variables, 0/0|1/10, )\n ScalarW/Assign (0/0 params, 0/0 flops, Assign, 0/0|1/1, 0:1|1:1)\n ScalarW/Initializer (0/0 params, 0/2 flops, _kTFScopeParent, 0/0|1/7, )\n ScalarW/Initializer/random_normal (0/0 params, 1/2 flops, Add, 0/0|1/6, 0:1|1:1)\n ScalarW/Initializer/random_normal/RandomStandardNormal (0/0 params, 0/0 flops, RandomStandardNormal, 0/0|1/1, 0:0)\n ScalarW/Initializer/random_normal/mean (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n ScalarW/Initializer/random_normal/mul (0/0 params, 1/1 flops, Mul, 0/0|1/1, 0:1|1:1)\n ScalarW/Initializer/random_normal/shape (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n ScalarW/Initializer/random_normal/stddev (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n ScalarW/read (0/0 params, 0/0 flops, Identity, 0/0|1/1, 0:1)\n _retval_Conv2D_1_0_0 (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|RunTimeOp, 1/1|1/1, )\n init (0/0 params, 0/0 flops, NoOp, 0/0|1/1, 0:1|1:3x3x3x6|2:2x2x6x12)\n zeros (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Const, 1/1|1/1, )\n',
f.read())
# pylint: enable=line-too-long