Define missing EIGEN_USE_THREADS in Tensorflow kernels.

Including Eigen/Tensor header with/without EIGEN_USE_THREADS define in different translation units (read kernels) is an ODR violation and leads to undefined behavior, and performance degradation: default eigen executor does no vectorization and does not use threads.

PiperOrigin-RevId: 277082344
Change-Id: I55e079979c2271d190ad0d1ee26dc713f4153262
This commit is contained in:
Eugene Zhulenev 2019-10-28 09:45:12 -07:00 committed by TensorFlower Gardener
parent 09a394544e
commit bbde233007
4 changed files with 13 additions and 5 deletions

View File

@ -12,6 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==============================================================================*/ ==============================================================================*/
#define EIGEN_USE_THREADS
#include "tensorflow/core/kernels/data/optional_ops.h" #include "tensorflow/core/kernels/data/optional_ops.h"
#include "tensorflow/core/common_runtime/dma_helper.h" #include "tensorflow/core/common_runtime/dma_helper.h"

View File

@ -13,23 +13,24 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==============================================================================*/ ==============================================================================*/
#include <limits>
#include "tensorflow/core/framework/allocator.h"
#define EIGEN_USE_THREADS #define EIGEN_USE_THREADS
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM #if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
#define EIGEN_USE_GPU #define EIGEN_USE_GPU
#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM #endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM
#include "tensorflow/core/kernels/list_kernels.h"
#include <limits>
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/allocator.h"
#include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/register_types.h" #include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h" #include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/framework/variant.h" #include "tensorflow/core/framework/variant.h"
#include "tensorflow/core/framework/variant_op_registry.h" #include "tensorflow/core/framework/variant_op_registry.h"
#include "tensorflow/core/kernels/concat_lib.h" #include "tensorflow/core/kernels/concat_lib.h"
#include "tensorflow/core/kernels/list_kernels.h"
#include "tensorflow/core/lib/core/coding.h" #include "tensorflow/core/lib/core/coding.h"
#include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/util/util.h" #include "tensorflow/core/util/util.h"

View File

@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==============================================================================*/ ==============================================================================*/
#define EIGEN_USE_THREADS
#include "tensorflow/core/kernels/nextafter_op.h" #include "tensorflow/core/kernels/nextafter_op.h"
#include "tensorflow/core/kernels/cwise_ops_common.h" #include "tensorflow/core/kernels/cwise_ops_common.h"

View File

@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==============================================================================*/ ==============================================================================*/
#define EIGEN_USE_THREADS
#include <stddef.h> #include <stddef.h>
#include <algorithm> #include <algorithm>