aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2016-02-23 11:09:05 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2016-02-23 11:09:05 +0100
commit91e1375ba97284d1a11068d27c039800ec7900f1 (patch)
treece96e6c443a28e1ea6d189b56cc08460c475b77c /unsupported/Eigen/CXX11/src/Tensor
parent055000a42466670d7fd0162f026cde9ab90f9b25 (diff)
parent1d9256f7db5db6c9f7fa915b4af868625f53502f (diff)
merge
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor')
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h17
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorFFT.h16
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h55
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h22
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h32
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h52
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h75
7 files changed, 43 insertions, 226 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h b/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h
index e254c0b7b..4e87813a9 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h
@@ -165,6 +165,18 @@ class TensorConversionOp : public TensorBase<TensorConversionOp<TargetType, XprT
typename XprType::Nested m_xpr;
};
+template <bool SameType, typename Eval, typename Scalar> struct ConversionSubExprEval {
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE static bool run(Eval& impl, Scalar*) {
+ impl.evalSubExprsIfNeeded(NULL);
+ return true;
+ }
+};
+
+template <typename Eval, typename Scalar> struct ConversionSubExprEval<true, Eval, Scalar> {
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE static bool run(Eval& impl, Scalar* data) {
+ return impl.evalSubExprsIfNeeded(data);
+ }
+};
@@ -195,10 +207,9 @@ struct TensorEvaluator<const TensorConversionOp<TargetType, ArgType>, Device>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_impl.dimensions(); }
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* /*data*/)
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar* data)
{
- m_impl.evalSubExprsIfNeeded(NULL);
- return true;
+ return ConversionSubExprEval<internal::is_same<TargetType, SrcType>::value, TensorEvaluator<ArgType, Device>, Scalar>::run(m_impl, data);
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void cleanup()
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorFFT.h b/unsupported/Eigen/CXX11/src/Tensor/TensorFFT.h
index aec5f4c8e..a5aa05da4 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorFFT.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorFFT.h
@@ -230,10 +230,10 @@ struct TensorEvaluator<const TensorFFTOp<FFT, ArgType, FFTResultType, FFTDir>, D
pos_j_base_powered[1] = pos_j_base;
if (line_len > 2) {
const ComplexScalar pos_j_base_sq = pos_j_base * pos_j_base;
- for (int i = 2; i < line_len + 1; ++i) {
- pos_j_base_powered[i] = pos_j_base_powered[i - 1] *
- pos_j_base_powered[i - 1] /
- pos_j_base_powered[i - 2] * pos_j_base_sq;
+ for (int j = 2; j < line_len + 1; ++j) {
+ pos_j_base_powered[j] = pos_j_base_powered[j - 1] *
+ pos_j_base_powered[j - 1] /
+ pos_j_base_powered[j - 2] * pos_j_base_sq;
}
}
}
@@ -468,7 +468,7 @@ struct TensorEvaluator<const TensorFFTOp<FFT, ArgType, FFTResultType, FFTDir>, D
template <int Dir>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void butterfly_1D_merge(
- ComplexScalar* data, int n, int n_power_of_2) {
+ ComplexScalar* data, Index n, Index n_power_of_2) {
// Original code:
// RealScalar wtemp = std::sin(M_PI/n);
// RealScalar wpi = -std::sin(2 * M_PI/n);
@@ -482,9 +482,9 @@ struct TensorEvaluator<const TensorFFTOp<FFT, ArgType, FFTResultType, FFTDir>, D
const ComplexScalar wp_one_2 = wp_one * wp_one;
const ComplexScalar wp_one_3 = wp_one_2 * wp_one;
const ComplexScalar wp_one_4 = wp_one_3 * wp_one;
- const int n2 = n / 2;
+ const Index n2 = n / 2;
ComplexScalar w(1.0, 0.0);
- for (int i = 0; i < n2; i += 4) {
+ for (Index i = 0; i < n2; i += 4) {
ComplexScalar temp0(data[i + n2] * w);
ComplexScalar temp1(data[i + 1 + n2] * w * wp_one);
ComplexScalar temp2(data[i + 2 + n2] * w * wp_one_2);
@@ -507,7 +507,7 @@ struct TensorEvaluator<const TensorFFTOp<FFT, ArgType, FFTResultType, FFTDir>, D
template <int Dir>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void compute_1D_Butterfly(
- ComplexScalar* data, int n, int n_power_of_2) {
+ ComplexScalar* data, Index n, Index n_power_of_2) {
eigen_assert(isPowerOfTwo(n));
if (n > 8) {
compute_1D_Butterfly<Dir>(data, n / 2, n_power_of_2 - 1);
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h b/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h
index 2ab332add..bc6021c9e 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h
@@ -167,7 +167,7 @@ struct TensorEvaluator<const TensorImagePatchOp<Rows, Cols, ArgType>, Device>
IsAligned = false,
PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
Layout = TensorEvaluator<ArgType, Device>::Layout,
- CoordAccess = NumDims == 5,
+ CoordAccess = false,
RawAccess = false
};
@@ -437,59 +437,6 @@ struct TensorEvaluator<const TensorImagePatchOp<Rows, Cols, ArgType>, Device>
Index rowInflateStride() const { return m_row_inflate_strides; }
Index colInflateStride() const { return m_col_inflate_strides; }
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(const array<Index, NumDims>& coords) const
- {
- // Location of the first element of the patch.
- // ColMajor
- // 0: d, 1: patch_rows, 2: patch_cols, 3: number of patches, 4: number of batches
- // RowMajor
- // 0: number of batches, 1: number of patches, 2: patch_cols , 3: patch_rows, 4: d
- const Index patch2DIndex = coords[static_cast<int>(Layout) == static_cast<int>(ColMajor) ? 3 : 1];
-
- array<Index, NumDims-1> inputCoords;
- Index input_col_idx = patch2DIndex / m_fastInputColsEff;
- Index inputCol = input_col_idx + coords[1] * m_in_row_strides - m_rowPaddingTop;
- Index inputRow = patch2DIndex - input_col_idx * m_input_cols_eff + coords[2] * m_in_col_strides - m_colPaddingLeft;
- const Index origInputCol = (m_col_inflate_strides == 1) ? inputCol : ((inputCol >= 0) ? (inputCol / m_fastInputColStride) : 0);
- const Index origInputRow = (m_row_inflate_strides == 1) ? inputRow : ((inputRow >= 0) ? (inputRow / m_fastInputRowStride) : 0);
- if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
- inputCoords[0] = coords[0]; // depth
- inputCoords[1] = origInputCol;
- inputCoords[2] = origInputRow;
- inputCoords[3] = coords[4]; // batch
- } else {
- inputCoords[3] = coords[4]; // depth
- inputCoords[2] = origInputCol;
- inputCoords[1] = origInputRow;
- inputCoords[0] = coords[0]; // batch
- }
- // If the computed coordinates are outside the original image perimeter, return 0.
- if (inputCol < 0 || inputCol >= m_input_cols_eff || inputRow < 0 || inputRow >= m_input_rows_eff ||
- ((m_col_inflate_strides != 1) && (inputCol != origInputCol * m_col_inflate_strides)) ||
- ((m_row_inflate_strides != 1) && (inputRow != origInputRow * m_row_inflate_strides))) {
- return Scalar(m_paddingValue);
- }
- if (TensorEvaluator<ArgType, Device>::CoordAccess) {
- return m_impl.coeff(inputCoords);
- } else {
- Index inputIndex;
- if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
- inputIndex =
- inputCoords[3] * m_patchInputStride +
- inputCoords[2] * m_colInputStride +
- inputCoords[1] * m_rowInputStride +
- inputCoords[0];
- } else {
- inputIndex =
- inputCoords[1] * m_patchInputStride +
- inputCoords[2] * m_colInputStride +
- inputCoords[3] * m_rowInputStride +
- inputCoords[4];
- }
- return m_impl.coeff(inputIndex);
- }
- }
-
protected:
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packetWithPossibleZero(Index index) const
{
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
index 11284315c..e867e450e 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
@@ -318,7 +318,7 @@ struct TensorEvaluator<const TensorSlicingOp<StartIndices, Sizes, ArgType>, Devi
IsAligned = /*TensorEvaluator<ArgType, Device>::IsAligned*/false,
PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
Layout = TensorEvaluator<ArgType, Device>::Layout,
- CoordAccess = TensorEvaluator<ArgType, Device>::CoordAccess,
+ CoordAccess = false,
RawAccess = false
};
@@ -457,15 +457,6 @@ struct TensorEvaluator<const TensorSlicingOp<StartIndices, Sizes, ArgType>, Devi
}
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(const array<Index, NumDims>& coords)
- {
- array<Index, NumDims> inputCoords;
- for (int i = 0; i < NumDims; ++i) {
- inputCoords = coords[i] + this->m_offsets[i];
- }
- return m_impl.coeff(inputCoords);
- }
-
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar* data() const {
Scalar* result = m_impl.data();
if (result) {
@@ -547,7 +538,7 @@ struct TensorEvaluator<TensorSlicingOp<StartIndices, Sizes, ArgType>, Device>
IsAligned = /*TensorEvaluator<ArgType, Device>::IsAligned*/false,
PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
Layout = TensorEvaluator<ArgType, Device>::Layout,
- CoordAccess = TensorEvaluator<ArgType, Device>::CoordAccess,
+ CoordAccess = false,
RawAccess = false
};
@@ -608,15 +599,6 @@ struct TensorEvaluator<TensorSlicingOp<StartIndices, Sizes, ArgType>, Device>
}
}
}
-
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType& coeffRef(const array<Index, NumDims>& coords)
- {
- array<Index, NumDims> inputCoords;
- for (int i = 0; i < NumDims; ++i) {
- inputCoords = coords[i] + this->m_offsets[i];
- }
- return this->m_impl.coeffRef(inputCoords);
- }
};
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h b/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h
index 39a305a93..c3f25f0df 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h
@@ -151,27 +151,27 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
for (int i = NumDims - 1; i > 0; --i) {
const Index idx = index / m_outputStrides[i];
if (idx < m_padding[i].first || idx >= m_dimensions[i] - m_padding[i].second) {
- return Scalar(0);
+ return internal::scalar_cast_op<int, Scalar>()(0);
}
inputIndex += (idx - m_padding[i].first) * m_inputStrides[i];
index -= idx * m_outputStrides[i];
}
if (index < m_padding[0].first || index >= m_dimensions[0] - m_padding[0].second) {
- return Scalar(0);
+ return internal::scalar_cast_op<int, Scalar>()(0);
}
inputIndex += (index - m_padding[0].first);
} else {
for (int i = 0; i < NumDims - 1; ++i) {
const Index idx = index / m_outputStrides[i+1];
if (idx < m_padding[i].first || idx >= m_dimensions[i] - m_padding[i].second) {
- return Scalar(0);
+ return internal::scalar_cast_op<int, Scalar>()(0);
}
inputIndex += (idx - m_padding[i].first) * m_inputStrides[i];
index -= idx * m_outputStrides[i+1];
}
if (index < m_padding[NumDims-1].first ||
index >= m_dimensions[NumDims-1] - m_padding[NumDims-1].second) {
- return Scalar(0);
+ return internal::scalar_cast_op<int, Scalar>()(0);
}
inputIndex += (index - m_padding[NumDims-1].first);
}
@@ -194,14 +194,14 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
{
const Index idx = coords[0];
if (idx < m_padding[0].first || idx >= m_dimensions[0] - m_padding[0].second) {
- return Scalar(0);
+ return internal::scalar_cast_op<int, Scalar>()(0);
}
inputIndex = idx - m_padding[0].first;
}
for (int i = 1; i < NumDims; ++i) {
const Index idx = coords[i];
if (idx < m_padding[i].first || idx >= m_dimensions[i] - m_padding[i].second) {
- return Scalar(0);
+ return internal::scalar_cast_op<int, Scalar>()(0);
}
inputIndex += (idx - m_padding[i].first) * m_inputStrides[i];
}
@@ -209,14 +209,14 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
{
const Index idx = coords[NumDims-1];
if (idx < m_padding[NumDims-1].first || idx >= m_dimensions[NumDims-1] - m_padding[NumDims-1].second) {
- return Scalar(0);
+ return internal::scalar_cast_op<int, Scalar>()(0);
}
inputIndex = idx - m_padding[NumDims-1].first;
}
for (int i = NumDims - 2; i >= 0; --i) {
const Index idx = coords[i];
if (idx < m_padding[i].first || idx >= m_dimensions[i] - m_padding[i].second) {
- return Scalar(0);
+ return internal::scalar_cast_op<int, Scalar>()(0);
}
inputIndex += (idx - m_padding[i].first) * m_inputStrides[i];
}
@@ -245,11 +245,11 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
if (last < lastPaddedLeft) {
// all the coefficient are in the padding zone.
- return internal::pset1<PacketReturnType>(Scalar(0));
+ return internal::pset1<PacketReturnType>(internal::scalar_cast_op<int, Scalar>()(0));
}
else if (first >= firstPaddedRight && last < lastPaddedRight) {
// all the coefficient are in the padding zone.
- return internal::pset1<PacketReturnType>(Scalar(0));
+ return internal::pset1<PacketReturnType>(internal::scalar_cast_op<int, Scalar>()(0));
}
else if (first >= lastPaddedLeft && last < firstPaddedRight) {
// all the coefficient are between the 2 padding zones.
@@ -271,11 +271,11 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
if (last < lastPaddedLeft) {
// all the coefficient are in the padding zone.
- return internal::pset1<PacketReturnType>(Scalar(0));
+ return internal::pset1<PacketReturnType>(internal::scalar_cast_op<int, Scalar>()(0));
}
else if (first >= firstPaddedRight && last < lastPaddedRight) {
// all the coefficient are in the padding zone.
- return internal::pset1<PacketReturnType>(Scalar(0));
+ return internal::pset1<PacketReturnType>(internal::scalar_cast_op<int, Scalar>()(0));
}
else if (first >= lastPaddedLeft && last < firstPaddedRight) {
// all the coefficient are between the 2 padding zones.
@@ -304,11 +304,11 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
if (last < lastPaddedLeft) {
// all the coefficient are in the padding zone.
- return internal::pset1<PacketReturnType>(Scalar(0));
+ return internal::pset1<PacketReturnType>(internal::scalar_cast_op<int, Scalar>()(0));
}
else if (first >= firstPaddedRight && last < lastPaddedRight) {
// all the coefficient are in the padding zone.
- return internal::pset1<PacketReturnType>(Scalar(0));
+ return internal::pset1<PacketReturnType>(internal::scalar_cast_op<int, Scalar>()(0));
}
else if (first >= lastPaddedLeft && last < firstPaddedRight) {
// all the coefficient are between the 2 padding zones.
@@ -330,11 +330,11 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
if (last < lastPaddedLeft) {
// all the coefficient are in the padding zone.
- return internal::pset1<PacketReturnType>(Scalar(0));
+ return internal::pset1<PacketReturnType>(internal::scalar_cast_op<int, Scalar>()(0));
}
else if (first >= firstPaddedRight && last < lastPaddedRight) {
// all the coefficient are in the padding zone.
- return internal::pset1<PacketReturnType>(Scalar(0));
+ return internal::pset1<PacketReturnType>(internal::scalar_cast_op<int, Scalar>()(0));
}
else if (first >= lastPaddedLeft && last < firstPaddedRight) {
// all the coefficient are between the 2 padding zones.
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h b/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h
index 2cbb820b1..57b716fd6 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorPatch.h
@@ -93,7 +93,7 @@ struct TensorEvaluator<const TensorPatchOp<PatchDim, ArgType>, Device>
IsAligned = false,
PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
Layout = TensorEvaluator<ArgType, Device>::Layout,
- CoordAccess = true,
+ CoordAccess = false,
RawAccess = false
};
@@ -248,56 +248,6 @@ struct TensorEvaluator<const TensorPatchOp<PatchDim, ArgType>, Device>
}
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(const array<Index, NumDims>& coords) const
- {
- Index patch_coord_idx = Layout == ColMajor ? NumDims - 1 : 0;
- // Location of the first element of the patch.
- const Index patchIndex = coords[patch_coord_idx];
-
- if (TensorEvaluator<ArgType, Device>::CoordAccess) {
- array<Index, NumDims-1> inputCoords;
- if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
- for (int i = NumDims - 2; i > 0; --i) {
- const Index patchIdx = patchIndex / m_patchStrides[i];
- patchIndex -= patchIdx * m_patchStrides[i];
- const Index offsetIdx = coords[i];
- inputCoords[i] = coords[i] + patchIdx;
- }
- } else {
- for (int i = 0; i < NumDims - 2; ++i) {
- const Index patchIdx = patchIndex / m_patchStrides[i];
- patchIndex -= patchIdx * m_patchStrides[i];
- const Index offsetIdx = coords[i+1];
- inputCoords[i] = coords[i+1] + patchIdx;
- }
- }
- Index coords_idx = Layout == ColMajor ? 0 : NumDims - 1;
- inputCoords[0] = (patchIndex + coords[coords_idx]);
- return m_impl.coeff(inputCoords);
- }
- else {
- Index inputIndex = 0;
- if (Layout == ColMajor) {
- for (int i = NumDims - 2; i > 0; --i) {
- const Index patchIdx = patchIndex / m_patchStrides[i];
- patchIndex -= patchIdx * m_patchStrides[i];
- const Index offsetIdx = coords[i];
- inputIndex += (patchIdx + offsetIdx) * m_inputStrides[i];
- }
- } else {
- for (int i = 0; i < NumDims - 2; ++i) {
- const Index patchIdx = patchIndex / m_patchStrides[i];
- patchIndex -= patchIdx * m_patchStrides[i];
- const Index offsetIdx = coords[i+1];
- inputIndex += (patchIdx + offsetIdx) * m_inputStrides[i];
- }
- }
- Index coords_idx = Layout == ColMajor ? 0 : NumDims - 1;
- inputIndex += (patchIndex + coords[coords_idx]);
- return m_impl.coeff(inputIndex);
- }
- }
-
EIGEN_DEVICE_FUNC Scalar* data() const { return NULL; }
protected:
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h b/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h
index 52b78b261..04f4f8ffc 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorVolumePatch.h
@@ -180,7 +180,7 @@ struct TensorEvaluator<const TensorVolumePatchOp<Planes, Rows, Cols, ArgType>, D
PacketAccess = TensorEvaluator<ArgType, Device>::PacketAccess,
BlockAccess = false,
Layout = TensorEvaluator<ArgType, Device>::Layout,
- CoordAccess = NumDims == 6,
+ CoordAccess = false,
RawAccess = false
};
@@ -518,79 +518,6 @@ struct TensorEvaluator<const TensorVolumePatchOp<Planes, Rows, Cols, ArgType>, D
Index rowInflateStride() const { return m_row_inflate_strides; }
Index colInflateStride() const { return m_col_inflate_strides; }
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(const array<Index, NumDims>& coords) const
- {
- // ColMajor
- // 0: depth, 1: patch_planes, 2: patch_rows, 3: patch_cols, 4: number of patches, 5: batches
- // RowMajor
- // 0: batches, 1: number of patches, 2: patch_cols , 3: patch_rows, 4: patch_planes, 5: depth
- const Index patch3DIndex = coords[static_cast<int>(Layout) == static_cast<int>(ColMajor) ? 4 : 1];
- const Index colOffset = coords[static_cast<int>(Layout) == static_cast<int>(ColMajor) ? 3 : 2];
- const Index rowOffset= coords[static_cast<int>(Layout) == static_cast<int>(ColMajor) ? 2 : 3];
- const Index planeOffset = coords[static_cast<int>(Layout) == static_cast<int>(ColMajor) ? 1 : 4];
-
- array<Index, NumDims-1> inputCoords;
-
- const Index colIndex = patch3DIndex / m_fastOutputPlanesRows;
- const Index inputCol = colIndex * m_col_strides + colOffset * m_in_col_strides - m_colPaddingLeft;
- const Index origInputCol = (m_col_inflate_strides == 1) ? inputCol : ((inputCol >= 0) ? (inputCol / m_fastInputColStride) : 0);
- if (inputCol < 0 || inputCol >= m_input_cols_eff ||
- ((m_col_inflate_strides != 1) && (inputCol != origInputCol * m_col_inflate_strides))) {
- return Scalar(m_paddingValue);
- }
-
- const Index rowIndex = (patch3DIndex - colIndex * m_outputPlanesRows) / m_fastOutputPlanes;
- const Index inputRow = rowIndex * m_row_strides + rowOffset * m_in_row_strides - m_rowPaddingTop;
- const Index origInputRow = (m_row_inflate_strides == 1) ? inputRow : ((inputRow >= 0) ? (inputRow / m_fastInputRowStride) : 0);
- if (inputRow < 0 || inputRow >= m_input_rows_eff ||
- ((m_row_inflate_strides != 1) && (inputRow != origInputRow * m_row_inflate_strides))) {
- return Scalar(m_paddingValue);
- }
-
- const Index planeIndex = patch3DIndex - colIndex * m_outputPlanesRows - rowIndex * m_outputRows;
- const Index inputPlane = planeIndex * m_plane_strides + planeOffset * m_in_plane_strides - m_planePaddingTop;
- const Index origInputPlane = (m_plane_inflate_strides == 1) ? inputPlane : ((inputPlane >= 0) ? (inputPlane / m_fastInputPlaneStride) : 0);
- if (inputPlane < 0 || inputPlane >= m_input_planes_eff ||
- ((m_plane_inflate_strides != 1) && (inputPlane != origInputPlane * m_plane_inflate_strides))) {
- return Scalar(m_paddingValue);
- }
-
- if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
- inputCoords[0] = coords[0]; // depth
- inputCoords[1] = origInputPlane;
- inputCoords[2] = origInputRow;
- inputCoords[3] = origInputCol;
- inputCoords[4] = coords[5]; // batch
- } else {
- inputCoords[4] = coords[5]; // depth
- inputCoords[3] = origInputPlane;
- inputCoords[2] = origInputRow;
- inputCoords[1] = origInputCol;
- inputCoords[0] = coords[0]; // batch
- }
- if (TensorEvaluator<ArgType, Device>::CoordAccess) {
- return m_impl.coeff(inputCoords);
- } else {
- Index inputIndex;
- if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
- inputIndex =
- inputCoords[4] * m_otherInputStride +
- inputCoords[3] * m_colInputStride +
- inputCoords[2] * m_rowInputStride +
- inputCoords[1] * m_planeInputStride +
- inputCoords[0];
- } else {
- inputIndex =
- inputCoords[0] * m_otherInputStride +
- inputCoords[1] * m_colInputStride +
- inputCoords[2] * m_rowInputStride +
- inputCoords[3] * m_planeInputStride +
- inputCoords[4];
- }
- return m_impl.coeff(inputIndex);
- }
- }
-
protected:
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packetWithPossibleZero(Index index) const
{