FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix for device_lib failures on python3 · codeplaysoftware/tensorflow@c05ca6b · GitHub

Repository navigation

Commit c05ca6b

Browse files
authored andcommitted
Fix for device_lib failures on python3
Change: 117682109
1 parent b59b69f commit c05ca6b

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎tensorflow/python/client/device_lib.i‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ limitations under the License.
3232
$1 = &temp;
3333
}
3434

35+
// Handle string input into AddDevices
36+
%typemap(in, numinputs=0) const string& name_prefix (
37+
string temp) {
38+
// Always pass an empty name_prefix.
39+
$1 = &temp;
40+
}
41+
3542
%typemap(argout) std::vector<tensorflow::Device*>* devices {
3643
std::vector< std::unique_ptr<tensorflow::Device> > safe_devices;
3744
for (auto* device : *$1) safe_devices.emplace_back(device);
@@ -54,10 +61,10 @@ limitations under the License.
5461
%#if PY_MAJOR_VERSION < 3
5562
PyString_FromStringAndSize(
5663
%#else
57-
PyUnicode_FromStringAndSize(
64+
PyBytes_FromStringAndSize(
5865
%#endif
59-
reinterpret_cast<const char*>(
60-
attr_serialized.data()), attr_serialized.size()));
66+
reinterpret_cast<const char*>(
67+
attr_serialized.data()), attr_serialized.size()));
6168

6269
if (PyList_Append(temp_string_list.get(), safe_attr_string.get()) == -1) {
6370
SWIG_fail;

‎tensorflow/python/client/device_lib.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ def _convert(pb_str):
3434
m = device_attributes_pb2.DeviceAttributes()
3535
m.ParseFromString(pb_str)
3636
return m
37-
return [_convert(s) for s in pywrap_tensorflow.DeviceFactory_AddDevices("")]
37+
return [_convert(s) for s in pywrap_tensorflow.DeviceFactory_AddDevices()]

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL