aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-07-27 16:09:26 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-07-27 16:13:15 -0700
commit13a9453aa3c9deccb0bccd7805fb1c34004a5525 (patch)
tree09e980eddf7626076e44c7855d8cffbdb4ce12f8 /tensorflow/core/kernels
parent2beb3a9d8b9df294e7635cc23d195a76fd78de79 (diff)
Remove references to std::string in MKL-related code.
tensorflow::string is sometimes ::string and sometimes std::string, which makes code that uses both subtly dangerous. For example, FactoryKeyCreator::AddAsKey() has an overload for tensorflow::string but had many callsites passing a std::string, causing incorrect behavior on the google platform. PiperOrigin-RevId: 206389641
Diffstat (limited to 'tensorflow/core/kernels')
-rw-r--r--tensorflow/core/kernels/mkl_concat_op.cc8
-rw-r--r--tensorflow/core/kernels/mkl_conv_grad_filter_ops.cc9
-rw-r--r--tensorflow/core/kernels/mkl_conv_grad_input_ops.cc9
-rw-r--r--tensorflow/core/kernels/mkl_conv_ops.cc17
-rw-r--r--tensorflow/core/kernels/mkl_conv_ops.h1
-rw-r--r--tensorflow/core/kernels/mkl_pooling_ops_common.h1
6 files changed, 19 insertions, 26 deletions
diff --git a/tensorflow/core/kernels/mkl_concat_op.cc b/tensorflow/core/kernels/mkl_concat_op.cc
index 6f490cdc23..d8efb1be3e 100644
--- a/tensorflow/core/kernels/mkl_concat_op.cc
+++ b/tensorflow/core/kernels/mkl_concat_op.cc
@@ -308,11 +308,9 @@ class MklConcatOp : public OpKernel {
}
if (invoke_eigen) {
- string msg = std::string("Invoking Eigen version of Concat. Reason:") +
- (!is_concat_dim_channel
- ? std::string("Concat dimension is not channel")
- : std::string("Not all tensors are in Mkl layout"));
- VLOG(1) << "_MklConcatOp: " << msg;
+ VLOG(1) << "_MklConcatOp: Invoking Eigen version of Concat. Reason:"
+ << (!is_concat_dim_channel ? "Concat dimension is not channel"
+ : "Not all tensors are in Mkl layout");
CallEigenVersion(context, input_tensors, input_shapes);
return;
}
diff --git a/tensorflow/core/kernels/mkl_conv_grad_filter_ops.cc b/tensorflow/core/kernels/mkl_conv_grad_filter_ops.cc
index a370037d97..b73a119a88 100644
--- a/tensorflow/core/kernels/mkl_conv_grad_filter_ops.cc
+++ b/tensorflow/core/kernels/mkl_conv_grad_filter_ops.cc
@@ -328,9 +328,8 @@ class MklConv2DBwdFilterPrimitiveFactory : public MklPrimitiveFactory<T> {
return instance_;
}
- static std::string CreateKey(
- const MklConvBwdFilterParams& convBwdFilterDims) {
- std::string prefix = "conv2d_bwd_filter";
+ static string CreateKey(const MklConvBwdFilterParams& convBwdFilterDims) {
+ string prefix = "conv2d_bwd_filter";
FactoryKeyCreator key_creator;
key_creator.AddAsKey(prefix);
key_creator.AddAsKey(convBwdFilterDims.src_dims);
@@ -346,13 +345,13 @@ class MklConv2DBwdFilterPrimitiveFactory : public MklPrimitiveFactory<T> {
MklPrimitive* GetConv2dBwdFilter(
const MklConvBwdFilterParams& convBwdFilterDims) {
- std::string key = CreateKey(convBwdFilterDims);
+ string key = CreateKey(convBwdFilterDims);
return this->GetOp(key);
}
void SetConv2dBwdFilter(
const MklConvBwdFilterParams& convBwdFilterDims, MklPrimitive* op) {
- std::string key = CreateKey(convBwdFilterDims);
+ string key = CreateKey(convBwdFilterDims);
this->SetOp(key, op);
}
};
diff --git a/tensorflow/core/kernels/mkl_conv_grad_input_ops.cc b/tensorflow/core/kernels/mkl_conv_grad_input_ops.cc
index b0f7faaa1a..39498f1a80 100644
--- a/tensorflow/core/kernels/mkl_conv_grad_input_ops.cc
+++ b/tensorflow/core/kernels/mkl_conv_grad_input_ops.cc
@@ -265,9 +265,8 @@ class MklConv2DBwdInputPrimitiveFactory : public MklPrimitiveFactory<T> {
return instance_;
}
- static std::string CreateKey(
- const MklConvBwdInputParams& convBwdInputDims) {
- std::string prefix = "conv2d_bwd_input";
+ static string CreateKey(const MklConvBwdInputParams& convBwdInputDims) {
+ string prefix = "conv2d_bwd_input";
FactoryKeyCreator key_creator;
key_creator.AddAsKey(prefix);
key_creator.AddAsKey(convBwdInputDims.diff_src_dims);
@@ -282,13 +281,13 @@ class MklConv2DBwdInputPrimitiveFactory : public MklPrimitiveFactory<T> {
MklPrimitive* GetConv2dBwdInput(
const MklConvBwdInputParams& convBwdInputDims) {
- std::string key = CreateKey(convBwdInputDims);
+ string key = CreateKey(convBwdInputDims);
return this->GetOp(key);
}
void SetConv2dBwdInput(
const MklConvBwdInputParams& convBwdInputDims, MklPrimitive *op) {
- std::string key = CreateKey(convBwdInputDims);
+ string key = CreateKey(convBwdInputDims);
this->SetOp(key, op);
}
};
diff --git a/tensorflow/core/kernels/mkl_conv_ops.cc b/tensorflow/core/kernels/mkl_conv_ops.cc
index b568973220..62396eeb8b 100644
--- a/tensorflow/core/kernels/mkl_conv_ops.cc
+++ b/tensorflow/core/kernels/mkl_conv_ops.cc
@@ -18,7 +18,6 @@ limitations under the License.
#include <string.h>
#include <map>
-#include <string>
#include <vector>
#include <memory>
@@ -35,6 +34,7 @@ limitations under the License.
#include "tensorflow/core/lib/gtl/array_slice.h"
#include "tensorflow/core/lib/strings/numbers.h"
#include "tensorflow/core/lib/strings/str_util.h"
+#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/macros.h"
#include "tensorflow/core/util/padding.h"
@@ -298,8 +298,8 @@ class MklConv2DFwdPrimitiveFactory : public MklPrimitiveFactory<T> {
return instance_;
}
- static std::string CreateKey(const MklConvFwdParams& convFwdDims) {
- std::string prefix = "conv2d_fwd_";
+ static string CreateKey(const MklConvFwdParams& convFwdDims) {
+ string prefix = "conv2d_fwd_";
FactoryKeyCreator key_creator;
key_creator.AddAsKey(prefix);
key_creator.AddAsKey(convFwdDims.src_dims);
@@ -314,12 +314,12 @@ class MklConv2DFwdPrimitiveFactory : public MklPrimitiveFactory<T> {
}
MklPrimitive* GetConv2DFwd(const MklConvFwdParams& convFwdDims) {
- std::string key = CreateKey(convFwdDims);
+ string key = CreateKey(convFwdDims);
return this->GetOp(key);
}
void SetConv2DFwd(const MklConvFwdParams& convFwdDims, MklPrimitive* op) {
- std::string key = CreateKey(convFwdDims);
+ string key = CreateKey(convFwdDims);
this->SetOp(key, op);
}
};
@@ -930,10 +930,9 @@ class MklConv2DOp : public OpKernel {
conv2d_fwd->Execute(src_data, filter_data, dst_data);
}
} catch (mkldnn::error &e) {
- string error_msg = "Status: " + std::to_string(e.status) +
- ", message: " + std::string(e.message) +
- ", in file " + std::string(__FILE__) + ":" +
- std::to_string(__LINE__);
+ string error_msg = tensorflow::strings::StrCat(
+ "Status: ", e.status, ", message: ", string(e.message), ", in file ",
+ __FILE__, ":", __LINE__);
OP_REQUIRES_OK(context,
errors::Aborted("Operation received an exception:", error_msg));
}
diff --git a/tensorflow/core/kernels/mkl_conv_ops.h b/tensorflow/core/kernels/mkl_conv_ops.h
index 5e1a5001dc..3f154ff33b 100644
--- a/tensorflow/core/kernels/mkl_conv_ops.h
+++ b/tensorflow/core/kernels/mkl_conv_ops.h
@@ -17,7 +17,6 @@ limitations under the License.
#define TENSORFLOW_CORE_KERNELS_MKL_CONV_OPS_H_
#include <limits>
-#include <string>
#include <vector>
#include <memory>
diff --git a/tensorflow/core/kernels/mkl_pooling_ops_common.h b/tensorflow/core/kernels/mkl_pooling_ops_common.h
index c0dfed7d7d..cb1eecb36a 100644
--- a/tensorflow/core/kernels/mkl_pooling_ops_common.h
+++ b/tensorflow/core/kernels/mkl_pooling_ops_common.h
@@ -17,7 +17,6 @@ limitations under the License.
#define TENSORFLOW_CORE_KERNELS_MKL_POOLING_OPS_COMMON_H_
#ifdef INTEL_MKL
-#include <string>
#include <vector>
#include "tensorflow/core/util/mkl_util.h"
#include "tensorflow/core/util/padding.h"