aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/index_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/compiler/xla/index_util.h')
-rw-r--r--tensorflow/compiler/xla/index_util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/index_util.h b/tensorflow/compiler/xla/index_util.h
index c9838966a5..0b9188e852 100644
--- a/tensorflow/compiler/xla/index_util.h
+++ b/tensorflow/compiler/xla/index_util.h
@@ -69,6 +69,18 @@ class IndexUtil {
// sizeof(dimension(3)) * sizeof(dimension(2)) == 4 * 10
static int64 GetDimensionStride(const Shape& shape, int64 dimension);
+ // Returns true iff the given multi-index is contained in the bounds for the
+ // shape.
+ static bool IndexInBounds(const Shape& shape,
+ tensorflow::gtl::ArraySlice<int64> index);
+
+ // Compares the given indices in lexicographic order. lhs[0] and rhs[0] are
+ // compared first, and lhs[rank-1] and rhs[rank-1] last. If lhs is larger,
+ // then -1 is returned. If rhs is larger, then 1 is returned. Otherwise, 0 is
+ // returned.
+ static int CompareIndices(tensorflow::gtl::ArraySlice<int64> lhs,
+ tensorflow::gtl::ArraySlice<int64> rhs);
+
private:
TF_DISALLOW_COPY_AND_ASSIGN(IndexUtil);
};