diff options
author | 2017-04-18 15:40:56 -0800 | |
---|---|---|
committer | 2017-04-18 16:51:23 -0700 | |
commit | 1c3e6c74d1eb63ebef2257c3eb7f3ee05ddd88d2 (patch) | |
tree | 6be8356c96680587e1030400afe87007d272d913 /tensorflow/core/kernels/tile_ops.cc | |
parent | 52e1c194ecf9aa4b2694eb1763a0d3e71df34bae (diff) |
[TF] Optimization of tf.tile: Skip allocation if multiples is all ones.
Change: 153528509
Diffstat (limited to 'tensorflow/core/kernels/tile_ops.cc')
-rw-r--r-- | tensorflow/core/kernels/tile_ops.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tensorflow/core/kernels/tile_ops.cc b/tensorflow/core/kernels/tile_ops.cc index 9822b021eb..06f20cd9ec 100644 --- a/tensorflow/core/kernels/tile_ops.cc +++ b/tensorflow/core/kernels/tile_ops.cc @@ -124,6 +124,10 @@ class TileOp : public OpKernel { multiples_array[i])); output_shape.AddDim(input.dim_size(i) * multiples_array[i]); } + if (output_shape == input.shape()) { + context->set_output(0, input); + return; + } Tensor* result = nullptr; OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &result)); @@ -315,6 +319,10 @@ class TileGradientOp : public OpKernel { output_shape.AddDim(input.dim_size(i) / multiples_array[i]); input_dim_size_vec.push_back(input.dim_size(i)); } + if (output_shape == input.shape()) { + context->set_output(0, input); + return; + } Tensor* result = nullptr; OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &result)); |