TensorImagePatch.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_IMAGE_PATCH_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_IMAGE_PATCH_H
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
32 namespace internal {
33 
34 template <DenseIndex Rows, DenseIndex Cols, typename XprType>
35 struct traits<TensorImagePatchOp<Rows, Cols, XprType> > : public traits<XprType> {
36  typedef std::remove_const_t<typename XprType::Scalar> Scalar;
38  typedef typename XprTraits::StorageKind StorageKind;
39  typedef typename XprTraits::Index Index;
40  typedef typename XprType::Nested Nested;
41  typedef std::remove_reference_t<Nested> Nested_;
42  static constexpr int NumDimensions = XprTraits::NumDimensions + 1;
43  static constexpr int Layout = XprTraits::Layout;
44  typedef typename XprTraits::PointerType PointerType;
45 };
46 
47 template <DenseIndex Rows, DenseIndex Cols, typename XprType>
48 struct eval<TensorImagePatchOp<Rows, Cols, XprType>, Eigen::Dense> {
50 };
51 
52 template <DenseIndex Rows, DenseIndex Cols, typename XprType>
53 struct nested<TensorImagePatchOp<Rows, Cols, XprType>, 1,
54  typename eval<TensorImagePatchOp<Rows, Cols, XprType> >::type> {
56 };
57 
58 template <typename Self, bool Vectorizable>
60  typedef typename Self::Index Index;
61  typedef typename Self::Scalar Scalar;
62  typedef typename Self::Impl Impl;
63  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void Run(const Self& self, const Index num_coeff_to_copy,
64  const Index dst_index, Scalar* dst_data,
65  const Index src_index) {
66  const Impl& impl = self.impl();
67  for (Index i = 0; i < num_coeff_to_copy; ++i) {
68  dst_data[dst_index + i] = impl.coeff(src_index + i);
69  }
70  }
71 };
72 
73 template <typename Self>
74 struct ImagePatchCopyOp<Self, true> {
75  typedef typename Self::Index Index;
76  typedef typename Self::Scalar Scalar;
77  typedef typename Self::Impl Impl;
79  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void Run(const Self& self, const Index num_coeff_to_copy,
80  const Index dst_index, Scalar* dst_data,
81  const Index src_index) {
82  const Impl& impl = self.impl();
84  const Index vectorized_size = (num_coeff_to_copy / packet_size) * packet_size;
85  for (Index i = 0; i < vectorized_size; i += packet_size) {
86  Packet p = impl.template packet<Unaligned>(src_index + i);
87  internal::pstoret<Scalar, Packet, Unaligned>(dst_data + dst_index + i, p);
88  }
89  for (Index i = vectorized_size; i < num_coeff_to_copy; ++i) {
90  dst_data[dst_index + i] = impl.coeff(src_index + i);
91  }
92  }
93 };
94 
95 template <typename Self>
97  typedef typename Self::Index Index;
98  typedef typename Self::Scalar Scalar;
100  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void Run(const Index num_coeff_to_pad, const Scalar padding_value,
101  const Index dst_index, Scalar* dst_data) {
103  const Packet padded_packet = internal::pset1<Packet>(padding_value);
104  const Index vectorized_size = (num_coeff_to_pad / packet_size) * packet_size;
105  for (Index i = 0; i < vectorized_size; i += packet_size) {
106  internal::pstoret<Scalar, Packet, Unaligned>(dst_data + dst_index + i, padded_packet);
107  }
108  for (Index i = vectorized_size; i < num_coeff_to_pad; ++i) {
109  dst_data[dst_index + i] = padding_value;
110  }
111  }
112 };
113 
114 } // end namespace internal
115 
116 template <DenseIndex Rows, DenseIndex Cols, typename XprType>
117 class TensorImagePatchOp : public TensorBase<TensorImagePatchOp<Rows, Cols, XprType>, ReadOnlyAccessors> {
118  public:
121  typedef typename XprType::CoeffReturnType CoeffReturnType;
125 
132  : m_xpr(expr),
141  m_padding_explicit(false),
142  m_padding_top(0),
143  m_padding_bottom(0),
144  m_padding_left(0),
145  m_padding_right(0),
148 
156  : m_xpr(expr),
165  m_padding_explicit(true),
172 
188 
190 
191  protected:
192  typename XprType::Nested m_xpr;
201  const bool m_padding_explicit;
208 };
209 
210 // Eval as rvalue
211 template <DenseIndex Rows, DenseIndex Cols, typename ArgType, typename Device>
212 struct TensorEvaluator<const TensorImagePatchOp<Rows, Cols, ArgType>, Device> {
214  typedef typename XprType::Index Index;
215  static constexpr int NumInputDims =
217  static constexpr int NumDims = NumInputDims + 1;
219  typedef std::remove_const_t<typename XprType::Scalar> Scalar;
227 
229  enum {
230  IsAligned = false,
232  BlockAccess = false,
233  PreferBlockAccess = true,
234  CoordAccess = false,
235  RawAccess = false
236  };
237 
238  //===- Tensor block evaluation strategy (see TensorBlock.h) -------------===//
240  //===--------------------------------------------------------------------===//
241 
242  EIGEN_STRONG_INLINE TensorEvaluator(const XprType& op, const Device& device)
243  : m_device(device), m_impl(op.expression(), device) {
244  EIGEN_STATIC_ASSERT((NumDims >= 4), YOU_MADE_A_PROGRAMMING_MISTAKE);
245 
246  m_paddingValue = op.padding_value();
247 
248  const typename TensorEvaluator<ArgType, Device>::Dimensions& input_dims = m_impl.dimensions();
249 
250  // Caches a few variables.
251  if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
252  m_inputDepth = input_dims[0];
253  m_inputRows = input_dims[1];
254  m_inputCols = input_dims[2];
255  } else {
256  m_inputDepth = input_dims[NumInputDims - 1];
257  m_inputRows = input_dims[NumInputDims - 2];
258  m_inputCols = input_dims[NumInputDims - 3];
259  }
260 
261  m_row_strides = op.row_strides();
262  m_col_strides = op.col_strides();
263 
264  // Input strides and effective input/patch size
265  m_in_row_strides = op.in_row_strides();
266  m_in_col_strides = op.in_col_strides();
267  m_row_inflate_strides = op.row_inflate_strides();
268  m_col_inflate_strides = op.col_inflate_strides();
269  // The "effective" input rows and input cols are the input rows and cols
270  // after inflating them with zeros.
271  // For examples, a 2x3 matrix with row_inflate_strides and
272  // col_inflate_strides of 2 comes from:
273  // A B C
274  // D E F
275  //
276  // to a matrix is 3 x 5:
277  //
278  // A . B . C
279  // . . . . .
280  // D . E . F
281 
282  m_input_rows_eff = (m_inputRows - 1) * m_row_inflate_strides + 1;
283  m_input_cols_eff = (m_inputCols - 1) * m_col_inflate_strides + 1;
284  m_patch_rows_eff = op.patch_rows() + (op.patch_rows() - 1) * (m_in_row_strides - 1);
285  m_patch_cols_eff = op.patch_cols() + (op.patch_cols() - 1) * (m_in_col_strides - 1);
286 
287  if (op.padding_explicit()) {
288  m_outputRows = numext::ceil((m_input_rows_eff + op.padding_top() + op.padding_bottom() - m_patch_rows_eff + 1.f) /
289  static_cast<float>(m_row_strides));
290  m_outputCols = numext::ceil((m_input_cols_eff + op.padding_left() + op.padding_right() - m_patch_cols_eff + 1.f) /
291  static_cast<float>(m_col_strides));
292  m_rowPaddingTop = op.padding_top();
293  m_colPaddingLeft = op.padding_left();
294  } else {
295  // Computing padding from the type
296  switch (op.padding_type()) {
297  case PADDING_VALID:
298  m_outputRows = numext::ceil((m_input_rows_eff - m_patch_rows_eff + 1.f) / static_cast<float>(m_row_strides));
299  m_outputCols = numext::ceil((m_input_cols_eff - m_patch_cols_eff + 1.f) / static_cast<float>(m_col_strides));
300  // Calculate the padding
301  m_rowPaddingTop =
302  numext::maxi<Index>(0, ((m_outputRows - 1) * m_row_strides + m_patch_rows_eff - m_input_rows_eff) / 2);
303  m_colPaddingLeft =
304  numext::maxi<Index>(0, ((m_outputCols - 1) * m_col_strides + m_patch_cols_eff - m_input_cols_eff) / 2);
305  break;
306  case PADDING_SAME:
307  m_outputRows = numext::ceil(m_input_rows_eff / static_cast<float>(m_row_strides));
308  m_outputCols = numext::ceil(m_input_cols_eff / static_cast<float>(m_col_strides));
309  // Calculate the padding
310  m_rowPaddingTop = ((m_outputRows - 1) * m_row_strides + m_patch_rows_eff - m_input_rows_eff) / 2;
311  m_colPaddingLeft = ((m_outputCols - 1) * m_col_strides + m_patch_cols_eff - m_input_cols_eff) / 2;
312  // The padding size calculation for PADDING_SAME has been updated to
313  // be consistent with how TensorFlow extracts its paddings.
314  m_rowPaddingTop = numext::maxi<Index>(0, m_rowPaddingTop);
315  m_colPaddingLeft = numext::maxi<Index>(0, m_colPaddingLeft);
316  break;
317  default:
318  eigen_assert(false && "unexpected padding");
319  m_outputCols = 0; // silence the uninitialised warning;
320  m_outputRows = 0;
321  }
322  }
323  eigen_assert(m_outputRows > 0);
324  eigen_assert(m_outputCols > 0);
325 
326  // Dimensions for result of extraction.
327  if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
328  // ColMajor
329  // 0: depth
330  // 1: patch_rows
331  // 2: patch_cols
332  // 3: number of patches
333  // 4 and beyond: anything else (such as batch).
334  m_dimensions[0] = input_dims[0];
335  m_dimensions[1] = op.patch_rows();
336  m_dimensions[2] = op.patch_cols();
337  m_dimensions[3] = m_outputRows * m_outputCols;
338  for (int i = 4; i < NumDims; ++i) {
339  m_dimensions[i] = input_dims[i - 1];
340  }
341  } else {
342  // RowMajor
343  // NumDims-1: depth
344  // NumDims-2: patch_rows
345  // NumDims-3: patch_cols
346  // NumDims-4: number of patches
347  // NumDims-5 and beyond: anything else (such as batch).
348  m_dimensions[NumDims - 1] = input_dims[NumInputDims - 1];
349  m_dimensions[NumDims - 2] = op.patch_rows();
350  m_dimensions[NumDims - 3] = op.patch_cols();
351  m_dimensions[NumDims - 4] = m_outputRows * m_outputCols;
352  for (int i = NumDims - 5; i >= 0; --i) {
353  m_dimensions[i] = input_dims[i];
354  }
355  }
356 
357  // Strides for moving the patch in various dimensions.
358  if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
359  m_colStride = m_dimensions[1];
360  m_patchStride = m_colStride * m_dimensions[2] * m_dimensions[0];
361  m_otherStride = m_patchStride * m_dimensions[3];
362  } else {
363  m_colStride = m_dimensions[NumDims - 2];
364  m_patchStride = m_colStride * m_dimensions[NumDims - 3] * m_dimensions[NumDims - 1];
365  m_otherStride = m_patchStride * m_dimensions[NumDims - 4];
366  }
367 
368  // Strides for navigating through the input tensor.
369  m_rowInputStride = m_inputDepth;
370  m_colInputStride = m_inputDepth * m_inputRows;
371  m_patchInputStride = m_inputDepth * m_inputRows * m_inputCols;
372 
373  // Fast representations of different variables.
374  m_fastOtherStride = internal::TensorIntDivisor<Index>(m_otherStride);
375  m_fastPatchStride = internal::TensorIntDivisor<Index>(m_patchStride);
376  m_fastColStride = internal::TensorIntDivisor<Index>(m_colStride);
377  m_fastInflateRowStride = internal::TensorIntDivisor<Index>(m_row_inflate_strides);
378  m_fastInflateColStride = internal::TensorIntDivisor<Index>(m_col_inflate_strides);
379  m_fastInputColsEff = internal::TensorIntDivisor<Index>(m_input_cols_eff);
380 
381  // Number of patches in the width dimension.
382  m_fastOutputRows = internal::TensorIntDivisor<Index>(m_outputRows);
383  if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) {
384  m_fastOutputDepth = internal::TensorIntDivisor<Index>(m_dimensions[0]);
385  } else {
386  m_fastOutputDepth = internal::TensorIntDivisor<Index>(m_dimensions[NumDims - 1]);
387  }
388  }
389 
390  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions& dimensions() const { return m_dimensions; }
391 
393  m_impl.evalSubExprsIfNeeded(NULL);
394  return true;
395  }
396 
397 #ifdef EIGEN_USE_THREADS
398  template <typename EvalSubExprsCallback>
399  EIGEN_STRONG_INLINE void evalSubExprsIfNeededAsync(EvaluatorPointerType, EvalSubExprsCallback done) {
400  m_impl.evalSubExprsIfNeededAsync(nullptr, [done](bool) { done(true); });
401  }
402 #endif // EIGEN_USE_THREADS
403 
404  EIGEN_STRONG_INLINE void cleanup() { m_impl.cleanup(); }
405 
407  // Patch index corresponding to the passed in index.
408  const Index patchIndex = index / m_fastPatchStride;
409  // Find the offset of the element wrt the location of the first element.
410  const Index patchOffset = (index - patchIndex * m_patchStride) / m_fastOutputDepth;
411 
412  // Other ways to index this element.
413  const Index otherIndex = (NumDims == 4) ? 0 : index / m_fastOtherStride;
414  const Index patch2DIndex = (NumDims == 4) ? patchIndex : (index - otherIndex * m_otherStride) / m_fastPatchStride;
415 
416  // Calculate col index in the input original tensor.
417  const Index colIndex = patch2DIndex / m_fastOutputRows;
418  const Index colOffset = patchOffset / m_fastColStride;
419  const Index inputCol = colIndex * m_col_strides + colOffset * m_in_col_strides - m_colPaddingLeft;
420  const Index origInputCol =
421  (m_col_inflate_strides == 1) ? inputCol : ((inputCol >= 0) ? (inputCol / m_fastInflateColStride) : 0);
422  if (inputCol < 0 || inputCol >= m_input_cols_eff ||
423  ((m_col_inflate_strides != 1) && (inputCol != origInputCol * m_col_inflate_strides))) {
424  return Scalar(m_paddingValue);
425  }
426 
427  // Calculate row index in the original input tensor.
428  const Index rowIndex = patch2DIndex - colIndex * m_outputRows;
429  const Index rowOffset = patchOffset - colOffset * m_colStride;
430  const Index inputRow = rowIndex * m_row_strides + rowOffset * m_in_row_strides - m_rowPaddingTop;
431  const Index origInputRow =
432  (m_row_inflate_strides == 1) ? inputRow : ((inputRow >= 0) ? (inputRow / m_fastInflateRowStride) : 0);
433  if (inputRow < 0 || inputRow >= m_input_rows_eff ||
434  ((m_row_inflate_strides != 1) && (inputRow != origInputRow * m_row_inflate_strides))) {
435  return Scalar(m_paddingValue);
436  }
437 
438  const int depth_index = static_cast<int>(Layout) == static_cast<int>(ColMajor) ? 0 : NumDims - 1;
439  const Index depth = index - (index / m_fastOutputDepth) * m_dimensions[depth_index];
440 
441  const Index inputIndex =
442  depth + origInputRow * m_rowInputStride + origInputCol * m_colInputStride + otherIndex * m_patchInputStride;
443  return m_impl.coeff(inputIndex);
444  }
445 
446  template <int LoadMode>
448  eigen_assert(index + PacketSize - 1 < dimensions().TotalSize());
449 
450  if (m_in_row_strides != 1 || m_in_col_strides != 1 || m_row_inflate_strides != 1 || m_col_inflate_strides != 1) {
451  return packetWithPossibleZero(index);
452  }
453 
454  const Index indices[2] = {index, index + PacketSize - 1};
455  const Index patchIndex = indices[0] / m_fastPatchStride;
456  if (patchIndex != indices[1] / m_fastPatchStride) {
457  return packetWithPossibleZero(index);
458  }
459  const Index otherIndex = (NumDims == 4) ? 0 : indices[0] / m_fastOtherStride;
460  eigen_assert(otherIndex == indices[1] / m_fastOtherStride);
461 
462  // Find the offset of the element wrt the location of the first element.
463  const Index patchOffsets[2] = {(indices[0] - patchIndex * m_patchStride) / m_fastOutputDepth,
464  (indices[1] - patchIndex * m_patchStride) / m_fastOutputDepth};
465 
466  const Index patch2DIndex =
467  (NumDims == 4) ? patchIndex : (indices[0] - otherIndex * m_otherStride) / m_fastPatchStride;
468  eigen_assert(patch2DIndex == (indices[1] - otherIndex * m_otherStride) / m_fastPatchStride);
469 
470  const Index colIndex = patch2DIndex / m_fastOutputRows;
471  const Index colOffsets[2] = {patchOffsets[0] / m_fastColStride, patchOffsets[1] / m_fastColStride};
472 
473  // Calculate col indices in the original input tensor.
474  const Index inputCols[2] = {colIndex * m_col_strides + colOffsets[0] - m_colPaddingLeft,
475  colIndex * m_col_strides + colOffsets[1] - m_colPaddingLeft};
476  if (inputCols[1] < 0 || inputCols[0] >= m_inputCols) {
477  return internal::pset1<PacketReturnType>(Scalar(m_paddingValue));
478  }
479 
480  if (inputCols[0] == inputCols[1]) {
481  const Index rowIndex = patch2DIndex - colIndex * m_outputRows;
482  const Index rowOffsets[2] = {patchOffsets[0] - colOffsets[0] * m_colStride,
483  patchOffsets[1] - colOffsets[1] * m_colStride};
484  eigen_assert(rowOffsets[0] <= rowOffsets[1]);
485  // Calculate col indices in the original input tensor.
486  const Index inputRows[2] = {rowIndex * m_row_strides + rowOffsets[0] - m_rowPaddingTop,
487  rowIndex * m_row_strides + rowOffsets[1] - m_rowPaddingTop};
488 
489  if (inputRows[1] < 0 || inputRows[0] >= m_inputRows) {
490  return internal::pset1<PacketReturnType>(Scalar(m_paddingValue));
491  }
492 
493  if (inputRows[0] >= 0 && inputRows[1] < m_inputRows) {
494  // no padding
495  const int depth_index = static_cast<int>(Layout) == static_cast<int>(ColMajor) ? 0 : NumDims - 1;
496  const Index depth = index - (index / m_fastOutputDepth) * m_dimensions[depth_index];
497  const Index inputIndex =
498  depth + inputRows[0] * m_rowInputStride + inputCols[0] * m_colInputStride + otherIndex * m_patchInputStride;
499  return m_impl.template packet<Unaligned>(inputIndex);
500  }
501  }
502 
503  return packetWithPossibleZero(index);
504  }
505 
506  EIGEN_DEVICE_FUNC EvaluatorPointerType data() const { return NULL; }
507 
509  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rowPaddingTop() const { return m_rowPaddingTop; }
510  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colPaddingLeft() const { return m_colPaddingLeft; }
511  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index outputRows() const { return m_outputRows; }
512  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index outputCols() const { return m_outputCols; }
513  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index userRowStride() const { return m_row_strides; }
514  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index userColStride() const { return m_col_strides; }
515  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index userInRowStride() const { return m_in_row_strides; }
516  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index userInColStride() const { return m_in_col_strides; }
517  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rowInflateStride() const { return m_row_inflate_strides; }
518  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colInflateStride() const { return m_col_inflate_strides; }
519 
521  // We conservatively estimate the cost for the code path where the computed
522  // index is inside the original image and
523  // TensorEvaluator<ArgType, Device>::CoordAccess is false.
524  const double compute_cost =
525  3 * TensorOpCost::DivCost<Index>() + 6 * TensorOpCost::MulCost<Index>() + 8 * TensorOpCost::MulCost<Index>();
526  return m_impl.costPerCoeff(vectorized) + TensorOpCost(0, 0, compute_cost, vectorized, PacketSize);
527  }
528 
529  protected:
531  EIGEN_ALIGN_MAX std::remove_const_t<CoeffReturnType> values[PacketSize];
533  for (int i = 0; i < PacketSize; ++i) {
534  values[i] = coeff(index + i);
535  }
536  PacketReturnType rslt = internal::pload<PacketReturnType>(values);
537  return rslt;
538  }
539 
541 
547 
552 
557 
564 
568 
572 
575 
578 
581 
583 
586 };
587 
588 } // end namespace Eigen
589 
590 #endif // EIGEN_CXX11_TENSOR_TENSOR_IMAGE_PATCH_H
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define EIGEN_ALIGN_MAX
Definition: ConfigureVectorization.h:146
#define EIGEN_UNROLL_LOOP
Definition: Macros.h:1298
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
#define EIGEN_DEVICE_REF
Definition: TensorMacros.h:34
float * p
Definition: Tutorial_Map_using.cpp:9
SCALAR Scalar
Definition: bench_gemm.cpp:45
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:79
The tensor base class.
Definition: TensorBase.h:1026
Definition: TensorImagePatch.h:117
EIGEN_DEVICE_FUNC DenseIndex padding_left() const
Definition: TensorImagePatch.h:184
EIGEN_DEVICE_FUNC DenseIndex patch_rows() const
Definition: TensorImagePatch.h:173
EIGEN_DEVICE_FUNC DenseIndex in_row_strides() const
Definition: TensorImagePatch.h:177
const DenseIndex m_padding_bottom
Definition: TensorImagePatch.h:203
EIGEN_DEVICE_FUNC DenseIndex in_col_strides() const
Definition: TensorImagePatch.h:178
EIGEN_DEVICE_FUNC PaddingType padding_type() const
Definition: TensorImagePatch.h:186
const Scalar m_padding_value
Definition: TensorImagePatch.h:207
EIGEN_DEVICE_FUNC DenseIndex col_inflate_strides() const
Definition: TensorImagePatch.h:180
EIGEN_DEVICE_FUNC DenseIndex col_strides() const
Definition: TensorImagePatch.h:176
const DenseIndex m_in_col_strides
Definition: TensorImagePatch.h:198
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorImagePatchOp(const XprType &expr, DenseIndex patch_rows, DenseIndex patch_cols, DenseIndex row_strides, DenseIndex col_strides, DenseIndex in_row_strides, DenseIndex in_col_strides, DenseIndex row_inflate_strides, DenseIndex col_inflate_strides, DenseIndex padding_top, DenseIndex padding_bottom, DenseIndex padding_left, DenseIndex padding_right, Scalar padding_value)
Definition: TensorImagePatch.h:149
const DenseIndex m_row_strides
Definition: TensorImagePatch.h:195
EIGEN_DEVICE_FUNC DenseIndex patch_cols() const
Definition: TensorImagePatch.h:174
EIGEN_DEVICE_FUNC DenseIndex padding_top() const
Definition: TensorImagePatch.h:182
const DenseIndex m_padding_right
Definition: TensorImagePatch.h:205
XprType::CoeffReturnType CoeffReturnType
Definition: TensorImagePatch.h:121
const DenseIndex m_padding_left
Definition: TensorImagePatch.h:204
Eigen::internal::traits< TensorImagePatchOp >::Scalar Scalar
Definition: TensorImagePatch.h:119
const DenseIndex m_patch_rows
Definition: TensorImagePatch.h:193
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorImagePatchOp(const XprType &expr, DenseIndex patch_rows, DenseIndex patch_cols, DenseIndex row_strides, DenseIndex col_strides, DenseIndex in_row_strides, DenseIndex in_col_strides, DenseIndex row_inflate_strides, DenseIndex col_inflate_strides, PaddingType padding_type, Scalar padding_value)
Definition: TensorImagePatch.h:126
EIGEN_DEVICE_FUNC bool padding_explicit() const
Definition: TensorImagePatch.h:181
EIGEN_DEVICE_FUNC DenseIndex row_strides() const
Definition: TensorImagePatch.h:175
EIGEN_DEVICE_FUNC DenseIndex row_inflate_strides() const
Definition: TensorImagePatch.h:179
const DenseIndex m_in_row_strides
Definition: TensorImagePatch.h:197
const DenseIndex m_col_strides
Definition: TensorImagePatch.h:196
const DenseIndex m_row_inflate_strides
Definition: TensorImagePatch.h:199
const PaddingType m_padding_type
Definition: TensorImagePatch.h:206
Eigen::internal::nested< TensorImagePatchOp >::type Nested
Definition: TensorImagePatch.h:122
Eigen::internal::traits< TensorImagePatchOp >::Index Index
Definition: TensorImagePatch.h:124
Eigen::internal::traits< TensorImagePatchOp >::StorageKind StorageKind
Definition: TensorImagePatch.h:123
XprType::Nested m_xpr
Definition: TensorImagePatch.h:192
const DenseIndex m_col_inflate_strides
Definition: TensorImagePatch.h:200
const DenseIndex m_padding_top
Definition: TensorImagePatch.h:202
EIGEN_DEVICE_FUNC DenseIndex padding_right() const
Definition: TensorImagePatch.h:185
const DenseIndex m_patch_cols
Definition: TensorImagePatch.h:194
EIGEN_DEVICE_FUNC const internal::remove_all_t< typename XprType::Nested > & expression() const
Definition: TensorImagePatch.h:189
const bool m_padding_explicit
Definition: TensorImagePatch.h:201
EIGEN_DEVICE_FUNC DenseIndex padding_bottom() const
Definition: TensorImagePatch.h:183
Eigen::NumTraits< Scalar >::Real RealScalar
Definition: TensorImagePatch.h:120
EIGEN_DEVICE_FUNC Scalar padding_value() const
Definition: TensorImagePatch.h:187
Definition: TensorCostModel.h:28
Definition: TensorBlock.h:566
@ ColMajor
Definition: Constants.h:318
char char * op
Definition: level2_impl.h:374
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar() ceil(const Scalar &x)
Definition: MathFunctions.h:1205
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
squared absolute value
Definition: GlobalFunctions.h:87
PaddingType
Definition: TensorTraits.h:227
@ PADDING_VALID
Definition: TensorTraits.h:227
@ PADDING_SAME
Definition: TensorTraits.h:227
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
Definition: Meta.h:75
Definition: Eigen_Colamd.h:49
Definition: Constants.h:519
T Real
Definition: NumTraits.h:183
Definition: TensorMeta.h:47
Definition: TensorForwardDeclarations.h:42
std::remove_const_t< typename XprType::Scalar > Scalar
Definition: TensorImagePatch.h:219
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colInflateStride() const
Definition: TensorImagePatch.h:518
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Definition: TensorImagePatch.h:406
internal::TensorBlockNotImplemented TensorBlock
Definition: TensorImagePatch.h:239
internal::TensorIntDivisor< Index > m_fastInflateRowStride
Definition: TensorImagePatch.h:561
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index userRowStride() const
Definition: TensorImagePatch.h:513
internal::TensorIntDivisor< Index > m_fastPatchStride
Definition: TensorImagePatch.h:559
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index outputRows() const
Definition: TensorImagePatch.h:511
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rowInflateStride() const
Definition: TensorImagePatch.h:517
EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
Definition: TensorImagePatch.h:242
TensorEvaluator< ArgType, Device > Impl
Definition: TensorImagePatch.h:221
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorEvaluator< ArgType, Device > & impl() const
Definition: TensorImagePatch.h:508
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colPaddingLeft() const
Definition: TensorImagePatch.h:510
XprType::CoeffReturnType CoeffReturnType
Definition: TensorImagePatch.h:222
internal::TensorIntDivisor< Index > m_fastOtherStride
Definition: TensorImagePatch.h:558
internal::TensorIntDivisor< Index > m_fastOutputRows
Definition: TensorImagePatch.h:579
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packetWithPossibleZero(Index index) const
Definition: TensorImagePatch.h:530
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rowPaddingTop() const
Definition: TensorImagePatch.h:509
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index userColStride() const
Definition: TensorImagePatch.h:514
internal::TensorIntDivisor< Index > m_fastInputColsEff
Definition: TensorImagePatch.h:563
DSizes< Index, NumDims > Dimensions
Definition: TensorImagePatch.h:218
EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType)
Definition: TensorImagePatch.h:392
internal::TensorIntDivisor< Index > m_fastInflateColStride
Definition: TensorImagePatch.h:562
EIGEN_STRONG_INLINE void cleanup()
Definition: TensorImagePatch.h:404
TensorImagePatchOp< Rows, Cols, ArgType > XprType
Definition: TensorImagePatch.h:213
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const
Definition: TensorImagePatch.h:506
const Device EIGEN_DEVICE_REF m_device
Definition: TensorImagePatch.h:584
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index outputCols() const
Definition: TensorImagePatch.h:512
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const
Definition: TensorImagePatch.h:447
TensorEvaluator< const TensorImagePatchOp< Rows, Cols, ArgType >, Device > Self
Definition: TensorImagePatch.h:220
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition: TensorImagePatch.h:390
StorageMemory< CoeffReturnType, Device > Storage
Definition: TensorImagePatch.h:225
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index userInRowStride() const
Definition: TensorImagePatch.h:515
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
Definition: TensorImagePatch.h:520
TensorEvaluator< ArgType, Device > m_impl
Definition: TensorImagePatch.h:585
PacketType< CoeffReturnType, Device >::type PacketReturnType
Definition: TensorImagePatch.h:223
internal::TensorIntDivisor< Index > m_fastOutputDepth
Definition: TensorImagePatch.h:580
internal::TensorIntDivisor< Index > m_fastColStride
Definition: TensorImagePatch.h:560
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index userInColStride() const
Definition: TensorImagePatch.h:516
A cost model used to limit the number of threads used for evaluating tensor expression.
Definition: TensorEvaluator.h:31
static constexpr int Layout
Definition: TensorEvaluator.h:46
Derived::Scalar Scalar
Definition: TensorEvaluator.h:33
const Device EIGEN_DEVICE_REF m_device
Definition: TensorEvaluator.h:170
Storage::Type EvaluatorPointerType
Definition: TensorEvaluator.h:41
@ PacketAccess
Definition: TensorEvaluator.h:50
@ IsAligned
Definition: TensorEvaluator.h:49
static constexpr int PacketSize
Definition: TensorEvaluator.h:38
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
Definition: TensorEvaluator.h:89
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
Definition: TensorEvaluator.h:69
Self::Impl Impl
Definition: TensorImagePatch.h:77
packet_traits< Scalar >::type Packet
Definition: TensorImagePatch.h:78
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void Run(const Self &self, const Index num_coeff_to_copy, const Index dst_index, Scalar *dst_data, const Index src_index)
Definition: TensorImagePatch.h:79
Self::Scalar Scalar
Definition: TensorImagePatch.h:76
Self::Index Index
Definition: TensorImagePatch.h:75
Definition: TensorImagePatch.h:59
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void Run(const Self &self, const Index num_coeff_to_copy, const Index dst_index, Scalar *dst_data, const Index src_index)
Definition: TensorImagePatch.h:63
Self::Scalar Scalar
Definition: TensorImagePatch.h:61
Self::Index Index
Definition: TensorImagePatch.h:60
Self::Impl Impl
Definition: TensorImagePatch.h:62
Definition: TensorImagePatch.h:96
Self::Index Index
Definition: TensorImagePatch.h:97
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void Run(const Index num_coeff_to_pad, const Scalar padding_value, const Index dst_index, Scalar *dst_data)
Definition: TensorImagePatch.h:100
Self::Scalar Scalar
Definition: TensorImagePatch.h:98
packet_traits< Scalar >::type Packet
Definition: TensorImagePatch.h:99
Definition: Meta.h:305
const TensorImagePatchOp< Rows, Cols, XprType > & type
Definition: TensorImagePatch.h:49
Definition: XprHelper.h:427
Definition: TensorTraits.h:152
ref_selector< T >::type type
Definition: TensorTraits.h:153
Definition: GenericPacketMath.h:108
XprTraits::StorageKind StorageKind
Definition: TensorImagePatch.h:38
std::remove_const_t< typename XprType::Scalar > Scalar
Definition: TensorImagePatch.h:36
XprType::Nested Nested
Definition: TensorImagePatch.h:40
XprTraits::Index Index
Definition: TensorImagePatch.h:39
traits< XprType > XprTraits
Definition: TensorImagePatch.h:37
XprTraits::PointerType PointerType
Definition: TensorImagePatch.h:44
std::remove_reference_t< Nested > Nested_
Definition: TensorImagePatch.h:41
Definition: ForwardDeclarations.h:21
Definition: GenericPacketMath.h:134