Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2eac53d

Browse files
author
Maciek Chociej
authored
Merge pull request tensorflow#10248 from caisq/branch_155393864
Branch 155393864
2 parents 3c49bfa + 9863871 commit 2eac53d

File tree

290 files changed

+5858
-2663
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+5858
-2663
lines changed

tensorflow/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ filegroup(
392392
"//tensorflow/tensorboard/demo:all_files",
393393
"//tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize:all_files",
394394
"//tensorflow/tensorboard/plugins:all_files",
395+
"//tensorflow/tensorboard/plugins/histograms:all_files",
395396
"//tensorflow/tensorboard/plugins/images:all_files",
396397
"//tensorflow/tensorboard/plugins/projector:all_files",
397398
"//tensorflow/tensorboard/plugins/scalars:all_files",

tensorflow/c/c_api.cc

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ using tensorflow::gtl::ArraySlice;
5959
using tensorflow::strings::StrCat;
6060
using tensorflow::AllocationDescription;
6161
using tensorflow::DataType;
62-
using tensorflow::Env;
6362
using tensorflow::Graph;
6463
using tensorflow::GraphDef;
65-
using tensorflow::mutex;
6664
using tensorflow::mutex_lock;
6765
using tensorflow::NameRangeMap;
6866
using tensorflow::NameRangesForNode;
@@ -77,7 +75,6 @@ using tensorflow::Reset;
7775
using tensorflow::RunMetadata;
7876
using tensorflow::RunOptions;
7977
using tensorflow::Session;
80-
using tensorflow::SessionOptions;
8178
using tensorflow::Status;
8279
using tensorflow::Tensor;
8380
using tensorflow::TensorBuffer;
@@ -718,6 +715,49 @@ TF_Buffer* TF_GetAllOpList() {
718715
return ret;
719716
}
720717

718+
// --------------------------------------------------------------------------
719+
// ListDevices & SessionListDevices API
720+
721+
void TF_DeleteDeviceList(TF_DeviceList* s) { delete s; }
722+
723+
TF_DeviceList* TF_SessionListDevices(TF_Session* session, TF_Status* status) {
724+
TF_DeviceList* response = new TF_DeviceList;
725+
status->status = session->session->ListDevices(&response->response);
726+
return response;
727+
}
728+
729+
TF_DeviceList* TF_DeprecatedSessionListDevices(TF_DeprecatedSession* session,
730+
TF_Status* status) {
731+
TF_DeviceList* response = new TF_DeviceList;
732+
status->status = session->session->ListDevices(&response->response);
733+
return response;
734+
}
735+
736+
int TF_DeviceListCount(const TF_DeviceList* list) {
737+
return list->response.size();
738+
}
739+
740+
#define TF_DEVICELIST_METHOD(return_type, method_name, accessor, err_val) \
741+
return_type method_name(const TF_DeviceList* list, const int index, \
742+
TF_Status* status) { \
743+
if (list == nullptr) { \
744+
status->status = InvalidArgument("list is null!"); \
745+
return err_val; \
746+
} \
747+
if (index < 0 || index >= list->response.size()) { \
748+
status->status = InvalidArgument("index out of bounds"); \
749+
return err_val; \
750+
} \
751+
return list->response[index].accessor; \
752+
}
753+
754+
TF_DEVICELIST_METHOD(const char*, TF_DeviceListName, name().c_str(), nullptr);
755+
TF_DEVICELIST_METHOD(const char*, TF_DeviceListType, device_type().c_str(),
756+
nullptr);
757+
TF_DEVICELIST_METHOD(int64_t, TF_DeviceListMemoryBytes, memory_limit(), -1);
758+
759+
#undef TF_DEVICELIST_METHOD
760+
721761
} // end extern "C"
722762

723763
// --------------------------------------------------------------------------

tensorflow/c/c_api.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,55 @@ TF_CAPI_EXPORT extern void TF_PRun(TF_DeprecatedSession*, const char* handle,
11831183
const char** target_oper_names, int ntargets,
11841184
TF_Status*);
11851185

1186+
typedef struct TF_DeviceList TF_DeviceList;
1187+
1188+
// Lists all devices in a TF_Session.
1189+
//
1190+
// Caller takes ownership of the returned TF_DeviceList* which must eventually
1191+
// be freed with a call to TF_DeleteDeviceList.
1192+
TF_CAPI_EXPORT extern TF_DeviceList* TF_SessionListDevices(TF_Session* session,
1193+
TF_Status* status);
1194+
1195+
// Lists all devices in a TF_Session.
1196+
//
1197+
// Caller takes ownership of the returned TF_DeviceList* which must eventually
1198+
// be freed with a call to TF_DeleteDeviceList.
1199+
TF_CAPI_EXPORT extern TF_DeviceList* TF_DeprecatedSessionListDevices(
1200+
TF_DeprecatedSession* session, TF_Status* status);
1201+
1202+
// Deallocates the device list.
1203+
TF_CAPI_EXPORT extern void TF_DeleteDeviceList(TF_DeviceList* list);
1204+
1205+
// Counts the number of elements in the device list.
1206+
TF_CAPI_EXPORT extern int TF_DeviceListCount(const TF_DeviceList* list);
1207+
1208+
// Retrieves the full name of the device (e.g. /job:worker/replica:0/...)
1209+
// The return value will be a pointer to a null terminated string. The caller
1210+
// must not modify or delete the string. It will be deallocated upon a call to
1211+
// TF_DeleteDeviceList.
1212+
//
1213+
// If index is out of bounds, an error code will be set in the status object,
1214+
// and a null pointer will be returned.
1215+
TF_CAPI_EXPORT extern const char* TF_DeviceListName(const TF_DeviceList* list,
1216+
int index, TF_Status*);
1217+
1218+
// Retrieves the type of the device at the given index.
1219+
//
1220+
// The caller must not modify or delete the string. It will be deallocated upon
1221+
// a call to TF_DeleteDeviceList.
1222+
//
1223+
// If index is out of bounds, an error code will be set in the status object,
1224+
// and a null pointer will be returned.
1225+
TF_CAPI_EXPORT extern const char* TF_DeviceListType(const TF_DeviceList* list,
1226+
int index, TF_Status*);
1227+
1228+
// Retrieve the amount of memory associated with a given device.
1229+
//
1230+
// If index is out of bounds, an error code will be set in the status object,
1231+
// and -1 will be returned.
1232+
TF_CAPI_EXPORT extern int64_t TF_DeviceListMemoryBytes(
1233+
const TF_DeviceList* list, int index, TF_Status*);
1234+
11861235
// --------------------------------------------------------------------------
11871236
// Load plugins containing custom ops and kernels
11881237

tensorflow/c/c_api_internal.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ limitations under the License.
2929
#include "tensorflow/core/platform/types.h"
3030
#include "tensorflow/core/common_runtime/shape_refiner.h"
3131

32-
3332
// Internal structures used by the C API. These are likely to change and should
3433
// not be depended on.
3534

@@ -114,3 +113,7 @@ struct TF_Session {
114113
struct TF_ImportGraphDefOptions {
115114
tensorflow::ImportGraphDefOptions opts;
116115
};
116+
117+
struct TF_DeviceList {
118+
std::vector<tensorflow::DeviceAttributes> response;
119+
};
8 Bytes
Binary file not shown.
8 Bytes
Binary file not shown.

tensorflow/cc/saved_model/testdata/half_plus_two_pbtxt/00000123/saved_model.pbtxt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ meta_graphs {
284284
type: "shape"
285285
default_value {
286286
shape {
287+
unknown_rank: true
287288
}
288289
}
289290
}
@@ -447,7 +448,7 @@ meta_graphs {
447448
}
448449
}
449450
tags: "serve"
450-
tensorflow_version: "1.0.0"
451+
tensorflow_version: "1.1.0-rc2"
451452
tensorflow_git_version: "unknown"
452453
}
453454
graph_def {
@@ -885,6 +886,7 @@ meta_graphs {
885886
key: "shape"
886887
value {
887888
shape {
889+
unknown_rank: true
888890
}
889891
}
890892
}
@@ -1714,7 +1716,7 @@ meta_graphs {
17141716
dtype: DT_STRING
17151717
tensor_shape {
17161718
}
1717-
string_val: "_temp_d286b725003942fd8bac94b6c67e7c0c/part"
1719+
string_val: "_temp_80e928f1e0c844239d136d1ea966099d/part"
17181720
}
17191721
}
17201722
}
@@ -2444,7 +2446,7 @@ meta_graphs {
24442446
input: "^save/restore_shard"
24452447
}
24462448
versions {
2447-
producer: 21
2449+
producer: 23
24482450
}
24492451
}
24502452
saver_def {

tensorflow/cc/training/coordinator_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class MockQueueRunner : public RunnerInterface {
7979
status, counter, start));
8080
}
8181

82-
Status Join() {
82+
Status Join() override {
8383
if (join_counter_ != nullptr) {
8484
(*join_counter_)++;
8585
}

tensorflow/compiler/aot/benchmark.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace benchmark {
4040
// the implementation without pulling in all of the Env dependencies.
4141
static double NowMicros() {
4242
struct timeval tv;
43-
gettimeofday(&tv, NULL);
43+
gettimeofday(&tv, nullptr);
4444
return static_cast<uint64>(tv.tv_sec) * 1000000 + tv.tv_usec;
4545
}
4646

tensorflow/compiler/jit/build_xla_launch_ops_pass.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ limitations under the License.
2323
#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
2424
#include "tensorflow/core/common_runtime/function.h"
2525
#include "tensorflow/core/common_runtime/optimization_registry.h"
26-
#include "tensorflow/core/framework/graph.pb.h"
2726
#include "tensorflow/core/framework/graph_def_util.h"
2827
#include "tensorflow/core/framework/node_def_builder.h"
2928
#include "tensorflow/core/framework/node_def_util.h"
@@ -32,7 +31,6 @@ limitations under the License.
3231
#include "tensorflow/core/graph/graph_constructor.h"
3332
#include "tensorflow/core/lib/core/status.h"
3433
#include "tensorflow/core/lib/hash/hash.h"
35-
#include "tensorflow/core/protobuf/config.pb.h"
3634
#include "tensorflow/core/public/version.h"
3735

3836
namespace tensorflow {

0 commit comments

Comments
 (0)