Merge pull request #21202 from bstriner:py37
PiperOrigin-RevId: 210447509
This commit is contained in:
commit
3455a9c6dd
tensorflow
8
tensorflow/c/eager/c_api.cc
Normal file → Executable file
8
tensorflow/c/eager/c_api.cc
Normal file → Executable file
@ -244,8 +244,8 @@ void TFE_ContextOptionsSetConfig(TFE_ContextOptions* options, const void* proto,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TFE_ContextOptionsSetAsync(TFE_ContextOptions* options,
|
void TFE_ContextOptionsSetAsync(TFE_ContextOptions* options,
|
||||||
unsigned char async) {
|
unsigned char enable) {
|
||||||
options->async = async;
|
options->async = enable;
|
||||||
}
|
}
|
||||||
void TFE_ContextOptionsSetDevicePlacementPolicy(
|
void TFE_ContextOptionsSetDevicePlacementPolicy(
|
||||||
TFE_ContextOptions* options, TFE_ContextDevicePlacementPolicy policy) {
|
TFE_ContextOptions* options, TFE_ContextDevicePlacementPolicy policy) {
|
||||||
@ -253,9 +253,9 @@ void TFE_ContextOptionsSetDevicePlacementPolicy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
TF_CAPI_EXPORT extern void TFE_ContextSetAsyncForThread(TFE_Context* ctx,
|
TF_CAPI_EXPORT extern void TFE_ContextSetAsyncForThread(TFE_Context* ctx,
|
||||||
unsigned char async,
|
unsigned char enable,
|
||||||
TF_Status* status) {
|
TF_Status* status) {
|
||||||
status->status = ctx->context.SetAsyncForThread(async);
|
status->status = ctx->context.SetAsyncForThread(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFE_DeleteContextOptions(TFE_ContextOptions* options) { delete options; }
|
void TFE_DeleteContextOptions(TFE_ContextOptions* options) { delete options; }
|
||||||
|
4
tensorflow/c/eager/c_api.h
Normal file → Executable file
4
tensorflow/c/eager/c_api.h
Normal file → Executable file
@ -76,7 +76,7 @@ typedef enum TFE_ContextDevicePlacementPolicy {
|
|||||||
// Sets the default execution mode (sync/async). Note that this can be
|
// Sets the default execution mode (sync/async). Note that this can be
|
||||||
// overridden per thread using TFE_ContextSetAsyncForThread.
|
// overridden per thread using TFE_ContextSetAsyncForThread.
|
||||||
TF_CAPI_EXPORT extern void TFE_ContextOptionsSetAsync(TFE_ContextOptions*,
|
TF_CAPI_EXPORT extern void TFE_ContextOptionsSetAsync(TFE_ContextOptions*,
|
||||||
unsigned char async);
|
unsigned char enable);
|
||||||
|
|
||||||
TF_CAPI_EXPORT extern void TFE_ContextOptionsSetDevicePlacementPolicy(
|
TF_CAPI_EXPORT extern void TFE_ContextOptionsSetDevicePlacementPolicy(
|
||||||
TFE_ContextOptions*, TFE_ContextDevicePlacementPolicy);
|
TFE_ContextOptions*, TFE_ContextDevicePlacementPolicy);
|
||||||
@ -114,7 +114,7 @@ TFE_ContextGetDevicePlacementPolicy(TFE_Context*);
|
|||||||
|
|
||||||
// Overrides the execution mode (sync/async) for the current thread.
|
// Overrides the execution mode (sync/async) for the current thread.
|
||||||
TF_CAPI_EXPORT extern void TFE_ContextSetAsyncForThread(TFE_Context*,
|
TF_CAPI_EXPORT extern void TFE_ContextSetAsyncForThread(TFE_Context*,
|
||||||
unsigned char async,
|
unsigned char enable,
|
||||||
TF_Status* status);
|
TF_Status* status);
|
||||||
|
|
||||||
// A tensorflow.ServerDef specifies remote workers (in addition to the current
|
// A tensorflow.ServerDef specifies remote workers (in addition to the current
|
||||||
|
2
tensorflow/python/eager/pywrap_tfe.h
Normal file → Executable file
2
tensorflow/python/eager/pywrap_tfe.h
Normal file → Executable file
@ -89,7 +89,7 @@ int MaybeRaiseExceptionFromStatus(const tensorflow::Status& status,
|
|||||||
PyObject* exception);
|
PyObject* exception);
|
||||||
|
|
||||||
// Returns the string associated with the passed-in python object.
|
// 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.
|
// Returns a unique id on each call.
|
||||||
int64_t get_uid();
|
int64_t get_uid();
|
||||||
|
@ -216,7 +216,7 @@ bool ParseStringValue(const string& key, PyObject* py_value, TF_Status* status,
|
|||||||
#if PY_MAJOR_VERSION >= 3
|
#if PY_MAJOR_VERSION >= 3
|
||||||
if (PyUnicode_Check(py_value)) {
|
if (PyUnicode_Check(py_value)) {
|
||||||
Py_ssize_t size = 0;
|
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;
|
if (buf == nullptr) return false;
|
||||||
*value = tensorflow::StringPiece(buf, size);
|
*value = tensorflow::StringPiece(buf, size);
|
||||||
return true;
|
return true;
|
||||||
@ -825,7 +825,7 @@ int MaybeRaiseExceptionFromStatus(const tensorflow::Status& status,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* TFE_GetPythonString(PyObject* o) {
|
const char* TFE_GetPythonString(PyObject* o) {
|
||||||
if (PyBytes_Check(o)) {
|
if (PyBytes_Check(o)) {
|
||||||
return PyBytes_AsString(o);
|
return PyBytes_AsString(o);
|
||||||
}
|
}
|
||||||
|
15
tensorflow/python/pywrap_tfe.i
Normal file → Executable file
15
tensorflow/python/pywrap_tfe.i
Normal file → Executable 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 {
|
%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 {
|
%typemap(in) const char* device_name {
|
||||||
if ($input == Py_None) {
|
if ($input == Py_None) {
|
||||||
$1 = nullptr;
|
$1 = nullptr;
|
||||||
} else {
|
} 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 {
|
%typemap(in) const char* op_name {
|
||||||
$1 = TFE_GetPythonString($input);
|
$1 = const_cast<char*>(TFE_GetPythonString($input));
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(in) (TFE_Context*) {
|
%typemap(in) (TFE_Context*) {
|
||||||
|
34
tensorflow/workspace.bzl
Normal file → Executable file
34
tensorflow/workspace.bzl
Normal file → Executable 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(
|
tf_http_archive(
|
||||||
name = "protobuf_archive",
|
name = "protobuf_archive",
|
||||||
urls = [
|
urls = PROTOBUF_URLS,
|
||||||
"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz",
|
sha256 = PROTOBUF_SHA256,
|
||||||
"https://github.com/google/protobuf/archive/v3.6.0.tar.gz",
|
strip_prefix = PROTOBUF_STRIP_PREFIX,
|
||||||
],
|
|
||||||
sha256 = "50a5753995b3142627ac55cfd496cebc418a2e575ca0236e29033c67bd5665f4",
|
|
||||||
strip_prefix = "protobuf-3.6.0",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# We need to import the protobuf library under the names com_google_protobuf
|
# 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.
|
# Unfortunately there is no way to alias http_archives at the moment.
|
||||||
tf_http_archive(
|
tf_http_archive(
|
||||||
name = "com_google_protobuf",
|
name = "com_google_protobuf",
|
||||||
urls = [
|
urls = PROTOBUF_URLS,
|
||||||
"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz",
|
sha256 = PROTOBUF_SHA256,
|
||||||
"https://github.com/google/protobuf/archive/v3.6.0.tar.gz",
|
strip_prefix = PROTOBUF_STRIP_PREFIX,
|
||||||
],
|
|
||||||
sha256 = "50a5753995b3142627ac55cfd496cebc418a2e575ca0236e29033c67bd5665f4",
|
|
||||||
strip_prefix = "protobuf-3.6.0",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
tf_http_archive(
|
tf_http_archive(
|
||||||
name = "com_google_protobuf_cc",
|
name = "com_google_protobuf_cc",
|
||||||
urls = [
|
urls = PROTOBUF_URLS,
|
||||||
"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz",
|
sha256 = PROTOBUF_SHA256,
|
||||||
"https://github.com/google/protobuf/archive/v3.6.0.tar.gz",
|
strip_prefix = PROTOBUF_STRIP_PREFIX,
|
||||||
],
|
|
||||||
sha256 = "50a5753995b3142627ac55cfd496cebc418a2e575ca0236e29033c67bd5665f4",
|
|
||||||
strip_prefix = "protobuf-3.6.0",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
tf_http_archive(
|
tf_http_archive(
|
||||||
|
Loading…
Reference in New Issue
Block a user