Merge pull request #21202 from bstriner:py37

PiperOrigin-RevId: 210447509
This commit is contained in:
TensorFlower Gardener 2018-08-27 16:03:35 -07:00
commit 3455a9c6dd
6 changed files with 37 additions and 30 deletions

8
tensorflow/c/eager/c_api.cc Normal file → Executable file
View File

@ -244,8 +244,8 @@ void TFE_ContextOptionsSetConfig(TFE_ContextOptions* options, const void* proto,
}
void TFE_ContextOptionsSetAsync(TFE_ContextOptions* options,
unsigned char async) {
options->async = async;
unsigned char enable) {
options->async = enable;
}
void TFE_ContextOptionsSetDevicePlacementPolicy(
TFE_ContextOptions* options, TFE_ContextDevicePlacementPolicy policy) {
@ -253,9 +253,9 @@ void TFE_ContextOptionsSetDevicePlacementPolicy(
}
TF_CAPI_EXPORT extern void TFE_ContextSetAsyncForThread(TFE_Context* ctx,
unsigned char async,
unsigned char enable,
TF_Status* status) {
status->status = ctx->context.SetAsyncForThread(async);
status->status = ctx->context.SetAsyncForThread(enable);
}
void TFE_DeleteContextOptions(TFE_ContextOptions* options) { delete options; }

4
tensorflow/c/eager/c_api.h Normal file → Executable file
View File

@ -76,7 +76,7 @@ typedef enum TFE_ContextDevicePlacementPolicy {
// Sets the default execution mode (sync/async). Note that this can be
// overridden per thread using TFE_ContextSetAsyncForThread.
TF_CAPI_EXPORT extern void TFE_ContextOptionsSetAsync(TFE_ContextOptions*,
unsigned char async);
unsigned char enable);
TF_CAPI_EXPORT extern void TFE_ContextOptionsSetDevicePlacementPolicy(
TFE_ContextOptions*, TFE_ContextDevicePlacementPolicy);
@ -114,7 +114,7 @@ TFE_ContextGetDevicePlacementPolicy(TFE_Context*);
// Overrides the execution mode (sync/async) for the current thread.
TF_CAPI_EXPORT extern void TFE_ContextSetAsyncForThread(TFE_Context*,
unsigned char async,
unsigned char enable,
TF_Status* status);
// A tensorflow.ServerDef specifies remote workers (in addition to the current

2
tensorflow/python/eager/pywrap_tfe.h Normal file → Executable file
View File

@ -89,7 +89,7 @@ int MaybeRaiseExceptionFromStatus(const tensorflow::Status& status,
PyObject* exception);
// Returns the string associated with the passed-in python object.
char* TFE_GetPythonString(PyObject* o);
const char* TFE_GetPythonString(PyObject* o);
// Returns a unique id on each call.
int64_t get_uid();

View File

@ -216,7 +216,7 @@ bool ParseStringValue(const string& key, PyObject* py_value, TF_Status* status,
#if PY_MAJOR_VERSION >= 3
if (PyUnicode_Check(py_value)) {
Py_ssize_t size = 0;
char* buf = PyUnicode_AsUTF8AndSize(py_value, &size);
const char* buf = PyUnicode_AsUTF8AndSize(py_value, &size);
if (buf == nullptr) return false;
*value = tensorflow::StringPiece(buf, size);
return true;
@ -825,7 +825,7 @@ int MaybeRaiseExceptionFromStatus(const tensorflow::Status& status,
return -1;
}
char* TFE_GetPythonString(PyObject* o) {
const char* TFE_GetPythonString(PyObject* o) {
if (PyBytes_Check(o)) {
return PyBytes_AsString(o);
}

15
tensorflow/python/pywrap_tfe.i Normal file → Executable file
View File

@ -105,20 +105,29 @@ limitations under the License.
}
}
// For const parameters in a function, SWIG pretty much ignores the const.
// See: http://www.swig.org/Doc2.0/SWIG.html#SWIG_nn13
// Hence the 'const_cast'.
%typemap(in) const char* serialized_function_def {
$1 = TFE_GetPythonString($input);
$1 = const_cast<char*>(TFE_GetPythonString($input));
}
// For const parameters in a function, SWIG pretty much ignores the const.
// See: http://www.swig.org/Doc2.0/SWIG.html#SWIG_nn13
// Hence the 'const_cast'.
%typemap(in) const char* device_name {
if ($input == Py_None) {
$1 = nullptr;
} else {
$1 = TFE_GetPythonString($input);
$1 = const_cast<char*>(TFE_GetPythonString($input));
}
}
// For const parameters in a function, SWIG pretty much ignores the const.
// See: http://www.swig.org/Doc2.0/SWIG.html#SWIG_nn13
// Hence the 'const_cast'.
%typemap(in) const char* op_name {
$1 = TFE_GetPythonString($input);
$1 = const_cast<char*>(TFE_GetPythonString($input));
}
%typemap(in) (TFE_Context*) {

34
tensorflow/workspace.bzl Normal file → Executable file
View File

@ -365,14 +365,18 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
},
)
PROTOBUF_URLS = [
"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz",
"https://github.com/google/protobuf/archive/v3.6.0.tar.gz",
]
PROTOBUF_SHA256 = "50a5753995b3142627ac55cfd496cebc418a2e575ca0236e29033c67bd5665f4"
PROTOBUF_STRIP_PREFIX = "protobuf-3.6.0"
tf_http_archive(
name = "protobuf_archive",
urls = [
"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz",
"https://github.com/google/protobuf/archive/v3.6.0.tar.gz",
],
sha256 = "50a5753995b3142627ac55cfd496cebc418a2e575ca0236e29033c67bd5665f4",
strip_prefix = "protobuf-3.6.0",
urls = PROTOBUF_URLS,
sha256 = PROTOBUF_SHA256,
strip_prefix = PROTOBUF_STRIP_PREFIX,
)
# We need to import the protobuf library under the names com_google_protobuf
@ -380,22 +384,16 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
# Unfortunately there is no way to alias http_archives at the moment.
tf_http_archive(
name = "com_google_protobuf",
urls = [
"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz",
"https://github.com/google/protobuf/archive/v3.6.0.tar.gz",
],
sha256 = "50a5753995b3142627ac55cfd496cebc418a2e575ca0236e29033c67bd5665f4",
strip_prefix = "protobuf-3.6.0",
urls = PROTOBUF_URLS,
sha256 = PROTOBUF_SHA256,
strip_prefix = PROTOBUF_STRIP_PREFIX,
)
tf_http_archive(
name = "com_google_protobuf_cc",
urls = [
"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz",
"https://github.com/google/protobuf/archive/v3.6.0.tar.gz",
],
sha256 = "50a5753995b3142627ac55cfd496cebc418a2e575ca0236e29033c67bd5665f4",
strip_prefix = "protobuf-3.6.0",
urls = PROTOBUF_URLS,
sha256 = PROTOBUF_SHA256,
strip_prefix = PROTOBUF_STRIP_PREFIX,
)
tf_http_archive(