aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/lib/core
Commit message (Collapse)AuthorAge
* Support converting eager tensor to tf.float16 if a numpy half is passed.Gravatar Akshay Modi2018-09-05
| | | | | | This still defaults to float32 for all normal floats. PiperOrigin-RevId: 211704918
* fix C++ header guards.Gravatar A. Unique TensorFlower2018-08-21
| | | | PiperOrigin-RevId: 209679086
* EIGEN_MAX_ALIGN_BYTES can be zero when vectorization is disabled. In that ↵Gravatar A. Unique TensorFlower2018-08-20
| | | | | | case, checking for alignment boundaries breaks due to division by zero. But in these cases the check itself is redundant, so replace EIGEN_MAX_ALIGN_BYTES with std::max(1, EIGEN_MAX_ALIGN_BYTES). PiperOrigin-RevId: 209513729
* Merge pull request #21319 from tensorflow:mrry-patch-1Gravatar TensorFlower Gardener2018-08-09
|\ | | | | | | PiperOrigin-RevId: 208075630
* | Fix build issue on mac with python-2.7.10 and clang 9.1.0Gravatar Yong Tang2018-08-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In PR 19993 the build issues on macOS with python2.7.10 and clang-9.1.0 were fixed. However, later on it looks like the order of `<locale>` and `<Python.h>` has been changed in https://github.com/tensorflow/tensorflow/commit/1e7b0e4ad6d0f57f3241fe0b80a65f2c2a7f11b0 possibly caused by `clang-format -i --style=`. This caused the build break of macOS with python-2.7.10 and clang 9.1.0 again. This fix updates the impacted files, and, adds an empty line in between so that future `clang-format -i --style` will not cuase build breaks. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
* | Fix potential use-after-free bug introduced in commitGravatar Asim Shankar2018-08-02
| | | | | | | | | | | | abb903df7a5998b33547c02e95f9fa47c00f31f4 PiperOrigin-RevId: 207145802
| * Add a defensive comment about the TOCTOU raceGravatar Derek Murray2018-08-02
| |
* | Python 3.7 Compatibility: Py_UnicodeAsUTF8AndSize() returns a "const char*"Gravatar Asim Shankar2018-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of a "char*". (See https://docs.python.org/3/whatsnew/3.7.html#c-api-changes) There are additional changes needed for Python 3.7 compatibility, this change just pulls out one of them (and subsumes a related attempt in #21202 and #20766) Helps with #20517 PiperOrigin-RevId: 207008013
| * [tf.py_func()] Check Python interpreter state before callGravatar Derek Murray2018-08-01
|/ | | Attempting to acquire the GIL in a destructor when the process is terminating can fail, leading to a hang. Fixes #21277.
* Fix import order in interpreter_wrapper.h.Gravatar Nupur Garg2018-07-13
| | | | PiperOrigin-RevId: 204429340
* [eager]: Fix bug in converting pandas objects to Tensors.Gravatar Asim Shankar2018-07-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, fix a segmentation fault when converting objects that implement the Python sequence protocol (i.e., __getitem__, __len__, and __iter__) but which do not have contiguous keys. Fixes #20347 However, there are still some discrepancies possible between tf.convert_to_tensor(o) (or tf.constant(o)) with and without eager execution enabled. Fixing those is left as a follow up excercise. Sample differences: (1) Empty sequences that have numpy conversions defined. import pandas as pd import tensorflow as tf s = pd.Series([]) # Empty series t = tf.constant(s) With eager execution enabled, t.dtype ends up with a dtype of float32 (as py_seq_tensor.cc considers empty lists to be float32) With graph construction, t.dtype ends up with a dtype of float64 (as make_tensor_proto() converts 's' to a numpy array and uses its dtype). (2) Objects that implement __getitem__, __len__, and __iter__, but are not convertible to numpy arrays (e.g., do not implement __array__): - With eager execution enabled, these can be converted to a tensor - For graph construction, the conversion fails. PiperOrigin-RevId: 203019624
* Merge changes from github.Gravatar Mingxing Tan2018-06-28
| | | | PiperOrigin-RevId: 202585094
* [TF:XLA] Add a XlaSort operator that directly wraps the Sort HLO.Gravatar Peter Hawkins2018-06-18
| | | | | | | | Merge XLA-specific operator registrations into a single file rather than having many tiny files. In passing, register a fill function for bfloat16 numpy type; needed for the np.arange() call in the sort unit test. PiperOrigin-RevId: 201005718
* [py_func]: Fix #20021Gravatar Asim Shankar2018-06-15
| | | | | | | | | | | | | | | | * EagerPyFunc now validates its assumption that returned tensors are backed by memory on the same device that the EagerPyFunc kernel executed on. * Make the Python trampolining mechanism ensure that this requirement of the kernel is met. * Allow tf.contrib.eager.py_func to execute correctly on devices other than CPU and GPU:0. Prior to this change, tf.contrib.eager.py_func() would copy data from CPU to GPU:0 if necessary, but not the other way around. As a result, the assumptions made by the EagerPyFunc kernel implementation about the placement of returned tensors would be violated. The test added in py_func_test.py, when executed on a machine with a GPU will: - Fail with a segmentation fault (dereferencing GPU memory) without the changes to py_func.cc and script_ops.py - Fail with an error message with the change to py_func.cc but without the change to script_ops.py - Pass with changes to py_func.cc and script_ops.py PiperOrigin-RevId: 200792057
* Ask NumPy for read only array when converting it to Tensor.Gravatar Eugene Zhulenev2018-06-08
| | | | | | | | | | | | | | Fix for: #17315 If numpy array is read-only, calling PyArray_FromAny with NPY_ARRAY_CARRAY flags introduce extra memory copy. Before: feed_cpu_variable_read_only: 5.6 GB/sec, min: 17.99, median: 19.54, mean: 19.76 After: feed_cpu_variable_read_only: 13.2 GB/sec, min: 7.60, median: 7.78, mean: 8.13 PiperOrigin-RevId: 199835695
* Use memmove instead of memcpy for the large tensors on Linux.Gravatar Eugene Zhulenev2018-06-06
| | | | | | | | | | | | | | | | | Issue: #17246 ~1.7x speedup for fetching a variable Before: fetch_cpu_variable : 5.5 GB/sec, min: 14.56, median: 15.05, mean: 15.14 fetch_cpu_variable_add: 11.0 GB/sec, min: 7.29, median: 12.03, mean: 12.56 fetch_cpu_variable_concat: 11.6 GB/sec, min: 6.92, median: 13.78, mean: 14.76 After: fetch_cpu_variable : 9.2 GB/sec, min: 8.71, median: 8.79, mean: 8.80 fetch_cpu_variable_add: 12.5 GB/sec, min: 6.41, median: 7.20, mean: 7.51 fetch_cpu_variable_concat: 12.7 GB/sec, min: 6.32, median: 6.54 PiperOrigin-RevId: 199497691
* When converting a numpy float64 to an EagerTensor, always ensure that itGravatar Akshay Modi2018-05-24
| | | | | | | | | becomes a float64 tensor. Earlier py_seq_tensor would fall back to a float32 if not explicitly requesting a float64 (which would not happen if we had no other information). PiperOrigin-RevId: 197977260
* Internal cleanup to remove a difference from the code on github.Gravatar A. Unique TensorFlower2018-05-23
| | | | PiperOrigin-RevId: 197817738
* ClangTidy - Readability cleanup:/code-findings-fixes.Gravatar A. Unique TensorFlower2018-05-14
| | | | | | | | | | * unused using-declarations * redundant string conversions * C-style casts * redundant get() call on smart pointer * the 'empty' method should be used to check for emptiness instead of 'size' PiperOrigin-RevId: 196585984
* Make CPython implementation function type-correct, which removes UB from ↵Gravatar A. Unique TensorFlower2018-05-13
| | | | | | calling a function through a pointer of the wrong type, and also removes a C-style cast. PiperOrigin-RevId: 196428430
* Merge changes from github.Gravatar Yifei Feng2018-04-23
| | | | PiperOrigin-RevId: 194031845
* Fix for: Suggest braces around initialization of subobject.Gravatar Brian Patton2018-04-20
| | | | PiperOrigin-RevId: 193717872
* Replaced calls to deprecated tensorflow::StringPiece methods with theirGravatar A. Unique TensorFlower2018-04-02
| | | | | | | | tensorflow::str_util equivalents. This will allow the deprecated methods to be removed. PiperOrigin-RevId: 191350894
* Raise exception in SWIG on bad TF_Status from C API.Gravatar Skye Wanderman-Milne2018-03-30
| | | | | | | | | | | | | | | This change provides an alternative mechanism to tf.raise_exception_on_not_ok_status(), which is inefficient and error-prone (people often use the status multiple times in the with block, but it's only checked when the context manager exits). Instead, it uses SWIG to automatically raise an exception when a C API method fails. Note that this removes the status argument from affected methods. For now, I've only applied this typemap to C API methods. It would be good to expand this to all uses of raise_exception_on_not_ok_status. PiperOrigin-RevId: 191121016
* Fix buffer overflow when fetching resources.Gravatar Alexandre Passos2018-03-25
| | | | PiperOrigin-RevId: 190273682
* Moves TensorHandle to common_runtimeGravatar Alexandre Passos2018-03-25
| | | | PiperOrigin-RevId: 190265301
* Fix another eager PyObject leakGravatar Allen Lavoie2018-03-12
| | | | | | Shockingly this one was also due to PySequence_GetItem. PiperOrigin-RevId: 188765548
* Extend TF Eager C API to allow asynchronous execution.Gravatar A. Unique TensorFlower2018-03-12
| | | | PiperOrigin-RevId: 188763442
* py_func attaches full stack traces when an error is raised.Gravatar Eugene Brevdo2018-03-07
| | | | | | This should help debugging errors that occur inside a py_func. PiperOrigin-RevId: 188238495
* Keep track of eager op device for tensor handles. Force-colocates ops using ↵Gravatar Alexandre Passos2018-03-01
| | | | | | resources with the resources. PiperOrigin-RevId: 187488175
* TFE: Register a GPU kernel for tfe.py_func.Gravatar Akshay Agrawal2018-01-29
| | | | PiperOrigin-RevId: 183765122
* Remove THIRD_PARTY_ from #include guardsGravatar Sanjoy Das2018-01-24
| | | | | | They don't make sense in the open source repository. PiperOrigin-RevId: 183140889
* Merge changes from github.Gravatar Jianwei Xie2018-01-24
| | | | PiperOrigin-RevId: 183100142
* Enable and fix some bfloat16 tests.Gravatar A. Unique TensorFlower2018-01-23
| | | | PiperOrigin-RevId: 183013346
* Merge changes from github.Gravatar A. Unique TensorFlower2017-12-22
| | | | PiperOrigin-RevId: 179953488
* Add comparison ufuncs for numpy bfloat16 type.Gravatar A. Unique TensorFlower2017-12-19
| | | | | | Fix 2 bfloat16 tests. PiperOrigin-RevId: 179614898
* Make bfloat16 works with complexGravatar A. Unique TensorFlower2017-12-13
| | | | PiperOrigin-RevId: 178917043
* Add tfe.py_func, a tf.py_func-like construct that wraps a Python function ↵Gravatar Akshay Agrawal2017-12-07
| | | | | | | | | | | | and executes it eagerly. In particular, an EagerPyFunc op is added that wraps a Python function and executes it eagerly. The wrapped function should take Tensors as inputs and return Tensors as outputs. Because functions wrapped in an EagerPyFunc are executed eagerly, they can make use of TensorFlow operations. EagerPyFunc should be differentiable, in principle; a gradient will be implemented and registered in a future change. Once a gradient is implemented, tfe.py_func will probably be the easiest mechanism for experimenting with custom ops. tfe.py_func will also make it easier to translate python functions with side-effects into defun-able code. PiperOrigin-RevId: 178303818
* Enable bfloat16 use from Python:Gravatar Peter Hawkins2017-12-04
| | | | | | | * add a bfloat16 Python type and NumPy extension. * allow the bfloat16 type in a number places in the Python libraries. PiperOrigin-RevId: 177875784
* Raise an exception when converting lists with invalid lengths to Tensors ↵Gravatar Allen Lavoie2017-11-29
| | | | | | instead of CHECK failing PiperOrigin-RevId: 177324815
* Change "safe pointers" to make the deleters stateless (i.e. a type, not a ↵Gravatar A. Unique TensorFlower2017-11-29
| | | | | | | | value). This decreases the size of each safe pointer object and allows more inlining of the destructor. PiperOrigin-RevId: 177292948
* Use LINKER_INITIALIZED for mutexes with static storage class.Gravatar A. Unique TensorFlower2017-11-21
| | | | | | | | | | | | | | | | | | | | | This was causing exit-time races as some threads were accessing the mutex as it was being destructed. --------------- It is illegal to use any static type with a constructor/destructor with static storage class in a multithreaded C++ programme that can exit(), even if the constructor is protected by C++11's function-scope static initialization rules, because exit-time destruction is unsafe in the presence of multiple threads. For things that are not function-scope, the construction is also unsafe, because global contruction ordering is undefined in general. The LINKER_INITIALIZED variant constructor for TensorFlow's mutex avoids these problems, at the cost of relying on the linker to zero-initialize the BSS region. PiperOrigin-RevId: 176612772
* Do not log an error when `tf.py_func()` raises `StopIteration`.Gravatar Derek Murray2017-11-15
| | | | | | | This reduces log spam when using `tf.py_func()` to wrap a Python generator, such as when using `tf.data.Dataset.from_generator()`. PiperOrigin-RevId: 175831781
* Removed StringPiece::set and StringPiece::clear, as they have no ↵Gravatar A. Unique TensorFlower2017-11-10
| | | | | | | | | | | | | absl::string_view equivalents. This will allow for a more convenient transition to absl::string_view. Calls to set StringPiece::set and StringPiece::clear were replaced with the StringPiece constructor as follows: string_piece_foo.set(data, size) => string_piece_foo = StringPiece(data, size) string_piece_foo.clear() => string_piece_foo = StringPiece() PiperOrigin-RevId: 175326576
* Unicode handling in py2 when eager execution is enabled.Gravatar Alexandre Passos2017-11-07
| | | | PiperOrigin-RevId: 174908577
* `tf.py_func`: Handle NumPy arrays of np.object that hold unicode strings.Gravatar Derek Murray2017-10-19
| | | | | | | This also fixes a bug affecting `tf.data.Dataset.from_generator()` on Python 3, where the generator yields Unicode (i.e. default) strings. PiperOrigin-RevId: 172798007
* Use "nullptr" instead of other null pointer constantsGravatar A. Unique TensorFlower2017-10-19
| | | | PiperOrigin-RevId: 172797910
* `tf.py_func`: Handle NumPy arrays of np.object that hold unicode strings.Gravatar Derek Murray2017-10-19
| | | | | | | This also fixes a bug affecting `tf.data.Dataset.from_generator()` on Python 3, where the generator yields Unicode (i.e. default) strings. PiperOrigin-RevId: 172798007
* Add uint32 and uint64 types to TensorFlow.Gravatar Peter Hawkins2017-10-10
| | | | | | | | This change merely creates the types, but does not register kernels that act on uint32/uint64 values. It also does not alter most op registration lists to include uint32/uint64 values. If desirable, that can be done in a subsequent change, although binary size will likely prove problematic if adding more kernels. The intent of the change is so XLA-compiled code can make use uint32/uint64 types. Since XLA does not use traditional TensorFlow kernels, using uint32/uint64 operators from XLA will require only uint32/uint64 op registrations, but will require few new kernel registrations. PiperOrigin-RevId: 171681867
* Move EagerTensor from python to C.Gravatar A. Unique TensorFlower2017-09-30
| | | | PiperOrigin-RevId: 170617321