diff options
author | 2016-03-24 08:44:27 -0800 | |
---|---|---|
committer | 2016-03-24 10:02:49 -0700 | |
commit | 821920c1f25968f5dfcd2f8999b293ebedf85957 (patch) | |
tree | b4dce0285bac385630f658582bf27558f80cac51 /tensorflow/core/lib/strings/strcat.cc | |
parent | 5b5b8412f0684a548e1e9001421e5d095cda0142 (diff) |
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<size_t NDIMS>
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 <typename... AV> 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
Diffstat (limited to 'tensorflow/core/lib/strings/strcat.cc')
-rw-r--r-- | tensorflow/core/lib/strings/strcat.cc | 2 |
1 files changed, 2 insertions, 0 deletions
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()); |