| 181 | |
| 182 | template <int LoadMode> |
| 183 | EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType |
| 184 | packet(Index index) const { |
| 185 | constexpr int kPacketSize = |
| 186 | internal::unpacket_traits<PacketReturnType>::size; |
| 187 | |
| 188 | EIGEN_STATIC_ASSERT(kPacketSize > 1, YOU_MADE_A_PROGRAMMING_MISTAKE) |
| 189 | eigen_assert(index + kPacketSize <= dimensions().TotalSize()); |
| 190 | |
| 191 | // Find the effective inner-most dimension where padding actually happens. |
| 192 | // NOTE: This is independent of index argument, and can be done in the |
| 193 | // constructor to save computation. However, if packet access does not |
| 194 | // happen, then moving to constructor will incur needless overhead. |
| 195 | int dim = -1; |
| 196 | if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) { |
| 197 | for (int k = 0; k < Dims; ++k) { |
| 198 | if (padding_[k].first != 0 || padding_[k].second != 0) { |
| 199 | dim = k; |
| 200 | break; |
| 201 | } |
| 202 | } |
| 203 | } else { |
| 204 | for (int k = Dims - 1; k >= 0; --k) { |
| 205 | if (padding_[k].first != 0 || padding_[k].second != 0) { |
| 206 | dim = k; |
| 207 | break; |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | const Index input_index = ToInputIndex(index); |
| 213 | |
| 214 | // If dim < 0, this means there is no padding at all. |
| 215 | if (dim < 0) { |
| 216 | return impl_.template packet<Unaligned>(input_index); |
| 217 | } |
| 218 | |
| 219 | // Check if the way from the begin of the packet to the end of the packet |
| 220 | // is paved with contiguous road. That is, the indices must be between the |
| 221 | // padded region in the effective inner-most dimension. |
| 222 | const Index left = padding_[dim].first * output_strides_[dim]; |
| 223 | const Index right = |
| 224 | (dimensions_[dim] - padding_[dim].second) * output_strides_[dim]; |
| 225 | |
| 226 | const Index index_mod = index % (dimensions_[dim] * output_strides_[dim]); |
| 227 | if (left <= index_mod && (index_mod + kPacketSize - 1) < right) { |
| 228 | return impl_.template packet<Unaligned>(input_index); |
| 229 | } |
| 230 | |
| 231 | // If the road is not contiguous, then fall back to coeff(). |
| 232 | EIGEN_ALIGN_MAX typename internal::remove_const<CoeffReturnType>::type |
| 233 | values[kPacketSize]; |
| 234 | values[0] = impl_.coeff(input_index); |
| 235 | for (int i = 1; i < kPacketSize; ++i) { |
| 236 | values[i] = coeff(index + i); |
| 237 | } |
| 238 | PacketReturnType result = internal::pload<PacketReturnType>(values); |
| 239 | return result; |
| 240 | } |
nothing calls this directly
no test coverage detected