Added support for convolution and reshaping of tensors.

This commit is contained in:
Benoit Steiner
2014-06-06 16:25:16 -07:00
parent 8998f4099e
commit a961d72e65
6 changed files with 413 additions and 2 deletions

View File

@@ -203,6 +203,13 @@ class TensorBase
return TensorContractionOp<const Dimensions, const Derived, const OtherDerived>(derived(), other.derived(), dims);
}
// Convolutions.
template<typename KernelDerived, typename Dimensions> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const TensorConvolutionOp<const Dimensions, const Derived, const KernelDerived>
convolve(const KernelDerived& kernel, const Dimensions& dims) const {
return TensorConvolutionOp<const Dimensions, const Derived, const KernelDerived>(derived(), kernel.derived(), dims);
}
// Coefficient-wise ternary operators.
template<typename ThenDerived, typename ElseDerived>
inline const TensorSelectOp<const Derived, const ThenDerived, const ElseDerived>
@@ -210,6 +217,13 @@ class TensorBase
return TensorSelectOp<const Derived, const ThenDerived, const ElseDerived>(derived(), thenTensor.derived(), elseTensor.derived());
}
// Morphing operators (slicing tbd).
template <typename NewDimensions>
inline const TensorReshapingOp<const Derived, const NewDimensions>
reshape(const NewDimensions& newDimensions) const {
return TensorReshapingOp<const Derived, const NewDimensions>(derived(), newDimensions);
}
// Select the device on which to evaluate the expression.
template <typename DeviceType>
TensorDevice<Derived, DeviceType> device(const DeviceType& device) {