From 0b1de747329250fbb290411d819bf10edbc1b858 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Wed, 29 Aug 2018 14:22:23 -0700 Subject: [PATCH] Documentation improvement in caffe2/core/tensor.h (#11006) Summary: Signed-off-by: Edward Z. Yang Pull Request resolved: https://github.com/pytorch/pytorch/pull/11006 Reviewed By: smessmer Differential Revision: D9558383 Pulled By: ezyang fbshipit-source-id: 7d36fb69a6e8a7d064da2c8796dc263a9fd4e094 --- caffe2/core/tensor.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/caffe2/core/tensor.h b/caffe2/core/tensor.h index 23740cfc5772e5..21dc126c7f2c0b 100644 --- a/caffe2/core/tensor.h +++ b/caffe2/core/tensor.h @@ -25,7 +25,7 @@ inline vector ToVectorTIndex(const std::vector& src) { } /** - * Return product of all dimensions starting from K + * Return product of all dimensions starting from k */ inline TIndex size_from_dim_(int k, const vector& dims) { TIndex r = 1; @@ -35,7 +35,7 @@ inline TIndex size_from_dim_(int k, const vector& dims) { return r; } -// Product of all dims up to +// Product of all dims up to k (not including dims[k]) inline TIndex size_to_dim_(int k, const vector& dims) { CAFFE_ENFORCE((unsigned)k <= dims.size()); TIndex r = 1; @@ -61,6 +61,7 @@ inline TIndex size_between_dim_(int k, int l, const vector& dims) { return r; } +// Wrap around axis_index if it is negative, s.t., -1 is the last dim inline int canonical_axis_index_(int axis_index, int ndims) { CAFFE_ENFORCE_GE(axis_index, -ndims); CAFFE_ENFORCE_LT(axis_index, ndims);