Do not use std::vector in getResourceRequirements
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h b/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h
index d7795a0..c4f6f86 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h
@@ -208,10 +208,11 @@
TensorOpCost(0, sizeof(CoeffReturnType), 0, vectorized, PacketSize);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- m_leftImpl.getResourceRequirements(resources);
- m_rightImpl.getResourceRequirements(resources);
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return internal::TensorBlockV2ResourceRequirements::merge(
+ m_leftImpl.getResourceRequirements(),
+ m_rightImpl.getResourceRequirements());
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void evalBlockV2(
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h b/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h
index 447da91..ba11bf7 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorBlock.h
@@ -65,40 +65,6 @@
kSkewedInnerDims
};
-struct TensorOpResourceRequirements {
- TensorBlockShapeType block_shape;
- Index block_total_size;
- // TODO(andydavis) Add 'target_num_threads' to support communication of
- // thread-resource requirements. This will allow ops deep in the
- // expression tree (like reductions) to communicate resources
- // requirements based on local state (like the total number of reductions
- // to be computed).
- TensorOpResourceRequirements(TensorBlockShapeType shape,
- const Index size)
- : block_shape(shape), block_total_size(size) {}
-};
-
-// Tries to merge multiple resource requirements.
-EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void MergeResourceRequirements(
- const std::vector<TensorOpResourceRequirements>& resources,
- TensorBlockShapeType* block_shape, Index* block_total_size) {
- if (resources.empty()) {
- return;
- }
- // TODO(andydavis) Implement different policies (i.e. revert to a default
- // policy if block shapes/sizes conflict).
- *block_shape = resources[0].block_shape;
- *block_total_size = resources[0].block_total_size;
- for (std::vector<TensorOpResourceRequirements>::size_type i = 1; i < resources.size(); ++i) {
- if (resources[i].block_shape == kSkewedInnerDims &&
- *block_shape != kSkewedInnerDims) {
- *block_shape = kSkewedInnerDims;
- }
- *block_total_size =
- numext::maxi(*block_total_size, resources[i].block_total_size);
- }
-}
-
/**
* \class TensorBlock
* \ingroup CXX11_Tensor_Module
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorBlockV2.h b/unsupported/Eigen/CXX11/src/Tensor/TensorBlockV2.h
index 221f8e8..6cacf1c 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorBlockV2.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorBlockV2.h
@@ -58,6 +58,60 @@
}
// -------------------------------------------------------------------------- //
+
+// Tensor block shape type defines what are the shape preference for the blocks
+// extracted from the larger tensor.
+//
+// Example: blocks of 100 elements from the large 100x100 tensor:
+// - tensor: 100x100
+// - target_block_size: 100
+//
+// TensorBlockShapeType:
+// - kUniformAllDims: 100 blocks of size 10x10
+// - kSkewedInnerDims: 100 blocks of size 100x1 (or 1x100 depending on a column
+// or row major layout)
+enum class TensorBlockV2ShapeType { kUniformAllDims, kSkewedInnerDims };
+
+struct TensorBlockV2ResourceRequirements {
+ TensorBlockV2ShapeType shape_type;
+ size_t size;
+
+ TensorBlockShapeType shapeV1() const {
+ return shape_type == TensorBlockV2ShapeType::kUniformAllDims
+ ? internal::kUniformAllDims
+ : internal::kSkewedInnerDims;
+ }
+
+ static TensorBlockV2ResourceRequirements
+ merge(const TensorBlockV2ResourceRequirements &lhs,
+ const TensorBlockV2ResourceRequirements &rhs) {
+ return {merge(lhs.shape_type, rhs.shape_type), merge(rhs.size, lhs.size)};
+ }
+
+ // This is a resource requirement that should be returned from expressions
+ // that do not have any block evaluation preference (e.g. default tensor
+ // expression with raw buffer access).
+ static TensorBlockV2ResourceRequirements any() {
+ return {TensorBlockV2ShapeType::kUniformAllDims, 1};
+ }
+
+private:
+ using Requirements = TensorBlockV2ResourceRequirements;
+
+ static size_t merge(size_t lhs_size, size_t rhs_size) {
+ return numext::maxi(lhs_size, rhs_size);
+ }
+
+ static TensorBlockV2ShapeType merge(TensorBlockV2ShapeType lhs,
+ TensorBlockV2ShapeType rhs) {
+ return (lhs == TensorBlockV2ShapeType::kSkewedInnerDims ||
+ rhs == TensorBlockV2ShapeType::kSkewedInnerDims)
+ ? TensorBlockV2ShapeType::kSkewedInnerDims
+ : TensorBlockV2ShapeType::kUniformAllDims;
+ }
+};
+
+// -------------------------------------------------------------------------- //
// TensorBlockDescriptor specifies a block offset within a tensor and the block
// sizes along each of the tensor dimensions.
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h b/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h
index 80162ad..454b0f7 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h
@@ -616,17 +616,16 @@
TensorOpCost(0, 0, compute_cost, vectorized, PacketSize);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
// TODO(wuke): Targeting L1 size is 30% faster than targeting L{-1} on large
// tensors. But this might need further tuning.
- Eigen::Index block_total_size_max = numext::maxi<Eigen::Index>(
+ const size_t target_block_size = numext::maxi<size_t>(
1, m_device.firstLevelCacheSize() / sizeof(Scalar));
- resources->push_back(internal::TensorOpResourceRequirements(
- internal::kSkewedInnerDims, block_total_size_max));
-
- m_impl.getResourceRequirements(resources);
+ return internal::TensorBlockV2ResourceRequirements::merge(
+ {internal::TensorBlockV2ShapeType::kSkewedInnerDims, target_block_size},
+ m_impl.getResourceRequirements());
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h b/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h
index 0981102..9b835c4 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h
@@ -294,13 +294,14 @@
TensorOpCost(0, 0, cost, vectorized, PacketSize);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- Eigen::Index block_total_size_max = numext::maxi<Eigen::Index>(
- 1, m_device.lastLevelCacheSize() / sizeof(Scalar));
- resources->push_back(internal::TensorOpResourceRequirements(
- internal::kSkewedInnerDims, block_total_size_max));
- m_impl.getResourceRequirements(resources);
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ const size_t target_block_size =
+ numext::maxi<size_t>(1, m_device.lastLevelCacheSize() / sizeof(Scalar));
+
+ return internal::TensorBlockV2ResourceRequirements::merge(
+ {internal::TensorBlockV2ShapeType::kSkewedInnerDims, target_block_size},
+ m_impl.getResourceRequirements());
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h b/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h
index 0273225..f9f90ec 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorConversion.h
@@ -397,9 +397,9 @@
}
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- m_impl.getResourceRequirements(resources);
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return m_impl.getResourceRequirements();
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h b/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h
index e6bb561..2cbc4e8 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorEvalTo.h
@@ -164,9 +164,9 @@
internal::pstoret<CoeffReturnType, PacketReturnType, Aligned>(m_buffer + i, m_impl.template packet<TensorEvaluator<ArgType, Device>::IsAligned ? Aligned : Unaligned>(i));
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- m_impl.getResourceRequirements(resources);
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return m_impl.getResourceRequirements();
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void evalBlockV2(
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h b/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h
index c031449..4085ad3 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorEvaluator.h
@@ -149,8 +149,10 @@
PacketType<CoeffReturnType, Device>::size);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>*) const {}
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return internal::TensorBlockV2ResourceRequirements::any();
+ }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
blockV2(TensorBlockDesc& desc, TensorBlockScratch& scratch,
@@ -320,8 +322,10 @@
PacketType<CoeffReturnType, Device>::size);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>*) const {}
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return internal::TensorBlockV2ResourceRequirements::any();
+ }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
blockV2(TensorBlockDesc& desc, TensorBlockScratch& scratch,
@@ -517,9 +521,9 @@
TensorOpCost(0, 0, functor_cost, vectorized, PacketSize);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- m_argImpl.getResourceRequirements(resources);
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return m_argImpl.getResourceRequirements();
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
@@ -655,10 +659,11 @@
TensorOpCost(0, 0, functor_cost, vectorized, PacketSize);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- m_leftImpl.getResourceRequirements(resources);
- m_rightImpl.getResourceRequirements(resources);
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return internal::TensorBlockV2ResourceRequirements::merge(
+ m_leftImpl.getResourceRequirements(),
+ m_rightImpl.getResourceRequirements());
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
@@ -934,11 +939,13 @@
.cwiseMax(m_elseImpl.costPerCoeff(vectorized));
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- m_condImpl.getResourceRequirements(resources);
- m_thenImpl.getResourceRequirements(resources);
- m_elseImpl.getResourceRequirements(resources);
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return internal::TensorBlockV2ResourceRequirements::merge(
+ m_condImpl.getResourceRequirements(),
+ internal::TensorBlockV2ResourceRequirements::merge(
+ m_thenImpl.getResourceRequirements(),
+ m_elseImpl.getResourceRequirements()));
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
index ca056e9..db123d8 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
@@ -182,25 +182,18 @@
TensorBlockScratch;
Evaluator evaluator(expr, device);
- Index total_size = array_prod(evaluator.dimensions());
- Index cache_size = device.firstLevelCacheSize() / sizeof(Scalar);
// TODO(ezhulenev): Do not use tiling for small tensors?
const bool needs_assign = evaluator.evalSubExprsIfNeeded(NULL);
if (needs_assign) {
- // Size tensor blocks to fit in cache (or requested target block size).
- Index block_total_size = numext::mini(cache_size, total_size);
- TensorBlockShapeType block_shape = kSkewedInnerDims;
// Query expression tree for desired block size/shape.
- std::vector<TensorOpResourceRequirements> resources;
- evaluator.getResourceRequirements(&resources);
- MergeResourceRequirements(resources, &block_shape, &block_total_size);
+ const TensorBlockV2ResourceRequirements requirements =
+ evaluator.getResourceRequirements();
- TensorBlockMapper block_mapper(
- TensorBlockDimensions(evaluator.dimensions()), block_shape,
- block_total_size);
- block_total_size = block_mapper.block_dims_total_size();
+ const TensorBlockMapper block_mapper(
+ TensorBlockDimensions(evaluator.dimensions()), requirements.shapeV1(),
+ requirements.size);
// Share scratch memory allocator between all blocks.
TensorBlockScratch scratch(device);
@@ -268,14 +261,10 @@
TensorExecutorTilingContext<TensorBlockMapper> GetTensorExecutorTilingContext(
const ThreadPoolDevice& device, const Evaluator& evaluator,
bool allocate_buffer = true) {
- // Prefer blocks skewed toward inner dimension.
- TensorBlockShapeType block_shape = kSkewedInnerDims;
- Index block_total_size = 0;
-
// Query expression tree for desired block size/shape.
- std::vector<TensorOpResourceRequirements> resources;
- evaluator.getResourceRequirements(&resources);
- MergeResourceRequirements(resources, &block_shape, &block_total_size);
+ const TensorBlockV2ResourceRequirements requirements =
+ evaluator.getResourceRequirements();
+
int num_threads = device.numThreads();
// Estimate minimum block size based on cost.
@@ -285,7 +274,7 @@
TensorBlockMapper block_mapper(
typename TensorBlockMapper::Dimensions(evaluator.dimensions()),
- block_shape, block_size);
+ requirements.shapeV1(), block_size);
block_size = block_mapper.block_dims_total_size();
const size_t align = numext::maxi(EIGEN_MAX_ALIGN_BYTES, 1);
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h b/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h
index 8d17d4b..95fa4f5 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h
@@ -176,8 +176,10 @@
return internal::ploadt<PacketReturnType, LoadMode>(m_buffer + index);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>*) const {}
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return internal::TensorBlockV2ResourceRequirements::any();
+ }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
blockV2(TensorBlockDesc& desc, TensorBlockScratch& scratch,
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h b/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h
index 77fa32d..bed7a1b 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorGenerator.h
@@ -167,12 +167,12 @@
return rslt;
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- Eigen::Index block_total_size_max = numext::maxi<Eigen::Index>(
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ const size_t target_block_size = numext::maxi<size_t>(
1, m_device.firstLevelCacheSize() / sizeof(Scalar));
- resources->push_back(internal::TensorOpResourceRequirements(
- internal::kSkewedInnerDims, block_total_size_max));
+ return {internal::TensorBlockV2ShapeType::kSkewedInnerDims,
+ target_block_size};
}
struct BlockIteratorState {
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h b/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h
index 76bed55..959e77e 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h
@@ -540,14 +540,6 @@
TensorOpCost(0, 0, compute_cost, vectorized, PacketSize);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- Eigen::Index block_total_size_max = numext::maxi<Eigen::Index>(
- 1, m_device.lastLevelCacheSize() / sizeof(Scalar));
- resources->push_back(internal::TensorOpResourceRequirements(
- internal::kSkewedInnerDims, block_total_size_max));
- }
-
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 d3628f9..7299cdc 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
@@ -198,10 +198,9 @@
return m_impl.costPerCoeff(vectorized);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>*) const {
- // TODO(ezhulenev): If we'll ever support block evaluation without raw
- // access we'll need to get requirements from `m_impl`.
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ return internal::TensorBlockV2ResourceRequirements::any();
}
// required in block(OutputTensorBlock* output_block) const
@@ -636,13 +635,13 @@
return m_impl.costPerCoeff(vectorized) + TensorOpCost(0, 0, m_is_identity ? 1 : NumDims);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- Eigen::Index block_total_size_max = numext::maxi<Eigen::Index>(
- 1, m_device.lastLevelCacheSize() / sizeof(Scalar));
- resources->push_back(internal::TensorOpResourceRequirements(
- internal::kSkewedInnerDims, block_total_size_max));
- m_impl.getResourceRequirements(resources);
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ const size_t target_block_size =
+ numext::maxi<size_t>(1, m_device.lastLevelCacheSize() / sizeof(Scalar));
+ return internal::TensorBlockV2ResourceRequirements::merge(
+ {internal::TensorBlockV2ShapeType::kSkewedInnerDims, target_block_size},
+ m_impl.getResourceRequirements());
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h b/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h
index 4d1a09a..0d74447 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorPadding.h
@@ -227,14 +227,13 @@
return cost;
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- Eigen::Index block_total_size_max = numext::maxi<Eigen::Index>(
- 1, m_device.lastLevelCacheSize() / sizeof(Scalar));
- resources->push_back(internal::TensorOpResourceRequirements(
- internal::kSkewedInnerDims, block_total_size_max));
-
- m_impl.getResourceRequirements(resources);
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ const size_t target_block_size =
+ numext::maxi<size_t>(1, m_device.lastLevelCacheSize() / sizeof(Scalar));
+ return internal::TensorBlockV2ResourceRequirements::merge(
+ {internal::TensorBlockV2ShapeType::kSkewedInnerDims, target_block_size},
+ m_impl.getResourceRequirements());
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h
index 0bb1e64..c600c31 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h
@@ -905,15 +905,6 @@
}
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- Eigen::Index block_total_size_max = numext::maxi<Eigen::Index>(
- 1, m_device.lastLevelCacheSize() / sizeof(Scalar));
- resources->push_back(internal::TensorOpResourceRequirements(
- internal::kSkewedInnerDims, block_total_size_max));
- m_impl.getResourceRequirements(resources);
- }
-
EIGEN_DEVICE_FUNC EvaluatorPointerType data() const { return m_result; }
EIGEN_DEVICE_FUNC const TensorEvaluator<ArgType, Device>& impl() const { return m_impl; }
EIGEN_DEVICE_FUNC const Device& device() const { return m_device; }
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h
index c5830da..0d18cfc 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h
@@ -248,12 +248,13 @@
return rslt;
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
- Eigen::Index block_total_size_max = numext::maxi<Eigen::Index>(
- 1, m_device.lastLevelCacheSize() / sizeof(Scalar));
- resources->push_back(internal::TensorOpResourceRequirements(
- internal::kSkewedInnerDims, block_total_size_max));
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
+ const size_t target_block_size =
+ numext::maxi<size_t>(1, m_device.lastLevelCacheSize() / sizeof(Scalar));
+ return internal::TensorBlockV2ResourceRequirements::merge(
+ {internal::TensorBlockV2ShapeType::kSkewedInnerDims, target_block_size},
+ m_impl.getResourceRequirements());
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h b/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h
index 655fd91..42bca81 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h
@@ -244,18 +244,19 @@
return PacketLoader<LoadMode, Self, TensorEvaluator<ArgType, Device>::PacketAccess>::Run(*this, index);
}
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void getResourceRequirements(
- std::vector<internal::TensorOpResourceRequirements>* resources) const {
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
+ internal::TensorBlockV2ResourceRequirements getResourceRequirements() const {
static const int inner_dim =
Layout == static_cast<int>(ColMajor) ? 0 : NumDims - 1;
- const bool inner_dim_shuffled = m_shuffle[inner_dim] != inner_dim;
- Eigen::Index block_total_size_max = numext::maxi<Eigen::Index>(
+ const size_t target_block_size = numext::maxi<size_t>(
1, m_device.firstLevelCacheSize() / sizeof(Scalar));
- resources->push_back(internal::TensorOpResourceRequirements(
- inner_dim_shuffled ? internal::kUniformAllDims
- : internal::kSkewedInnerDims,
- block_total_size_max));
+
+ const bool inner_dim_shuffled = m_shuffle[inner_dim] != inner_dim;
+ return {inner_dim_shuffled
+ ? internal::TensorBlockV2ShapeType::kUniformAllDims
+ : internal::TensorBlockV2ShapeType::kSkewedInnerDims,
+ target_block_size};
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlockV2