Replaced calls to deprecated tensorflow::StringPiece methods with their
authorA. Unique TensorFlower <gardener@tensorflow.org>
Sat, 7 Apr 2018 00:19:45 +0000 (17:19 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Sat, 7 Apr 2018 01:14:38 +0000 (18:14 -0700)
tensorflow::str_util equivalents.

This will allow the deprecated methods to be removed.

PiperOrigin-RevId: 191962763

tensorflow/compiler/xla/tests/xla_internal_test_main.cc
tensorflow/core/framework/op_kernel.cc
tensorflow/core/grappler/optimizers/arithmetic_optimizer.cc
tensorflow/core/platform/s3/s3_file_system.cc

index 0af40bc..a9f2915 100644 (file)
@@ -15,6 +15,7 @@ limitations under the License.
 
 #include "tensorflow/compiler/xla/legacy_flags/debug_options_flags.h"
 #include "tensorflow/core/lib/core/stringpiece.h"
+#include "tensorflow/core/lib/strings/str_util.h"
 #include "tensorflow/core/platform/logging.h"
 #include "tensorflow/core/platform/test.h"
 #include "tensorflow/core/platform/test_benchmark.h"
@@ -32,14 +33,15 @@ GTEST_API_ int main(int argc, char** argv) {
   // tests.
   for (int i = 1; i < argc; i++) {
     tensorflow::StringPiece arg(argv[i]);
-    if (arg == "--benchmarks" || arg.starts_with("--benchmarks=")) {
+    if (arg == "--benchmarks" ||
+        tensorflow::str_util::StartsWith(arg, "--benchmarks=")) {
       const char* pattern = nullptr;
-      if (arg.starts_with("--benchmarks=")) {
+      if (tensorflow::str_util::StartsWith(arg, "--benchmarks=")) {
         pattern = argv[i] + strlen("--benchmarks=");
       } else {
         // Handle flag of the form '--benchmarks foo' (no '=').
         if (i + 1 >= argc ||
-            tensorflow::StringPiece(argv[i + 1]).starts_with("--")) {
+            tensorflow::str_util::StartsWith(argv[i + 1], "--")) {
           LOG(ERROR) << "--benchmarks flag requires an argument.";
           return 2;
         }
index cfde1e8..0517100 100644 (file)
@@ -96,7 +96,7 @@ OpKernel::OpKernel(OpKernelConstruction* context,
       output_memory_types_(context->output_memory_types().begin(),
                            context->output_memory_types().end()),
       graph_def_version_(context->graph_def_version()),
-      is_internal_(StringPiece(type_string()).starts_with("_")),
+      is_internal_(str_util::StartsWith(type_string(), "_")),
       input_name_map_(context->num_inputs()),
       output_name_map_(context->num_outputs()) {
   OP_REQUIRES_OK(context,
index 7bf264b..da8d677 100644 (file)
@@ -475,7 +475,7 @@ class AddOpsRewriteStage : public ArithmeticOptimizerStage {
       return false;
     }
     // it must not be created by this stage at any of previous optimization runs
-    if (StringPiece(node->name()).contains(stage_name_)) {
+    if (str_util::StrContains(node->name(), stage_name_)) {
       return false;
     }
     // should not drive or be driven by control dependency
index ee42369..6da679d 100644 (file)
@@ -156,7 +156,7 @@ Status ParseS3Path(const string& fname, bool empty_object_ok, string* bucket,
     return errors::InvalidArgument("S3 path doesn't contain a bucket name: ",
                                    fname);
   }
-  objectp.Consume("/");
+  str_util::ConsumePrefix(&objectp, "/");
   *object = objectp.ToString();
   if (!empty_object_ok && object->empty()) {
     return errors::InvalidArgument("S3 path doesn't contain an object name: ",