From 821920c1f25968f5dfcd2f8999b293ebedf85957 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Thu, 24 Mar 2016 08:44:27 -0800 Subject: Several changes to reduce TensorFlow code size (especially important for mobile apps): (1) Change many interfaces in node_def_builder.h, node_def_util.h, op_kernel.h, node_builder.h, mirror_pad_mode.h, padding.h to use 'StringPiece', rather than 'const string&'. The interfaces that were changed tend to be heavily used in the registration of ops and kernels, and often caused extra string construction code to be emitted in the macro expansion of each op or kernel registration. (2) Move some repetitive CHECK operations into non-inlined routines in tensor.cc, rather than having them in inlined or templated routines in tensor.h (new Tensor::CheckDataType, Tensor::CheckTypeAndIsAligned, and Tensor::CheckIsAlignedAndSingleElement routines) (3) Factored out internal template Tensor::FillDimsAndValidateCompatibleShape routine, to be shared across more specialized templated routines (typically specialized on both DataType and NDIMS). (4) Added new non-inlined TensorShape::CheckDimsMatch(int NDIMS) routine in tensor_shape.cc, that can be called from various TensorShape routines templated on NDIMS. (5) Don't inline single-argument StrCat, since it involves a string creation, etc. (6) Remove inline keyword from template StrCat version that handles 5 or more arguments. Reduces text size for third_party/tensorflow/core/libandroid_tensorflow_lib.so built in Google build environment by 1.43%, as measured by: % blaze build -c opt --config=android_arm \ third_party/tensorflow/core:android_tensorflow_lib % size blaze-bin/third_party/tensorflow/core/libandroid_tensorflow_lib.so Change: 118036659 --- tensorflow/core/lib/strings/strcat.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tensorflow/core/lib/strings/strcat.cc') diff --git a/tensorflow/core/lib/strings/strcat.cc b/tensorflow/core/lib/strings/strcat.cc index 4050727dc0..0c659e236c 100644 --- a/tensorflow/core/lib/strings/strcat.cc +++ b/tensorflow/core/lib/strings/strcat.cc @@ -84,6 +84,8 @@ static char *Append4(char *out, const AlphaNum &x1, const AlphaNum &x2, return out + x4.size(); } +string StrCat(const AlphaNum &a) { return string(a.data(), a.size()); } + string StrCat(const AlphaNum &a, const AlphaNum &b) { string result; gtl::STLStringResizeUninitialized(&result, a.size() + b.size()); -- cgit v1.2.3