aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework/tensor.h
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-09-24 11:04:14 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-24 11:11:38 -0700
commit3bb3257a5f9675e6c094b9a6318d96d1bc27fc94 (patch)
tree730f2680227453abd863c1ed2661cab32635e167 /tensorflow/core/framework/tensor.h
parentf7017ef769bd603b61f25dfffc772e2153a9f076 (diff)
Add functionality to SubSlice a tensor.
PiperOrigin-RevId: 214295534
Diffstat (limited to 'tensorflow/core/framework/tensor.h')
-rw-r--r--tensorflow/core/framework/tensor.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/tensorflow/core/framework/tensor.h b/tensorflow/core/framework/tensor.h
index e412329498..8a0c70fef2 100644
--- a/tensorflow/core/framework/tensor.h
+++ b/tensorflow/core/framework/tensor.h
@@ -200,10 +200,29 @@ class Tensor {
/// must check the returned tensor's alignment before calling certain
/// methods that have alignment requirement (e.g., `flat()`, `tensor()`).
///
+ /// NOTE: When fed with an N-dimensional tensor, this method returns a tensor
+ /// also with N dimensions. If you want to select a sub tensor, see SubSlice.
+ ///
/// REQUIRES: `dims()` >= 1
/// REQUIRES: `0 <= dim0_start <= dim0_limit <= dim_size(0)`
Tensor Slice(int64 dim0_start, int64 dim0_limit) const;
+ /// \brief Select a subslice from this tensor along the 1st dimension.
+ ///
+ /// When fed with an N-dimensional tensor, this method returns a tensor with
+ /// N-1 dimensions, where the returned tensor is a subslice of the input
+ /// tensor along the first dimension. The N-1 dimensions of the returned
+ /// tensor are the last N-1 dimensions of the input tensor.
+ ///
+ /// NOTE: The returned tensor may not satisfy the same alignment
+ /// requirement as this tensor depending on the shape. The caller
+ /// must check the returned tensor's alignment before calling certain
+ /// methods that have alignment requirement (e.g., `flat()`, `tensor()`).
+ ///
+ /// REQUIRES: `dims()` >= 2
+ /// REQUIRES: `0 <= dim0_start < dim_size(0)`
+ Tensor SubSlice(int64 index) const;
+
/// \brief Parse `other` and construct the tensor.
/// Returns `true` iff the parsing succeeds. If the parsing fails,