112 RankCombinationViewType rank_combination_types)
114 tensor_view_iterator_(tensor_view),
115 view1_iterator_(view1),
116 view2_iterator_(view2),
117 rank_combination_types_(rank_combination_types)
135 unsigned max_component_rank = (view1.rank() > view2.rank()) ? view1.rank() : view2.rank();
136 unsigned max_rank = (tensor_view.rank() > max_component_rank) ? tensor_view.rank() : max_component_rank;
140 unsigned expected_rank = 0;
141 bool contracting =
false;
142 for (
unsigned d=0; d<rank_combination_types.extent(0); d++)
144 if (rank_combination_types[d] == TENSOR_CONTRACTION)
155 if (rank_combination_types[d] == TENSOR_PRODUCT)
157 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(tensor_view.extent_int(d) != view1.extent_int(d) * view2.extent_int(d), std::invalid_argument,
"For TENSOR_PRODUCT rank combination, the tensor View must have length in that dimension equal to the product of the two component views in that dimension");
161 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(view1.extent_int(d) != view2.extent_int(d), std::invalid_argument,
"For DIMENSION_MATCH rank combination, all three views must have length equal to each other in that rank");
162 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(tensor_view.extent_int(d) != view1.extent_int(d), std::invalid_argument,
"For DIMENSION_MATCH rank combination, all three views must have length equal to each other in that rank");
202 if (view2_next_increment_rank > view1_next_increment_rank)
205 device_assert(rank_combination_types_[view2_next_increment_rank]==TENSOR_PRODUCT);
206 view1_iterator_.
reset(view2_next_increment_rank);
209 return view2_next_increment_rank;
213 int view1_rank_change = view1_iterator_.
increment();
214 if (view1_rank_change >= 0)
216 switch (rank_combination_types_[view1_rank_change])
218 case DIMENSION_MATCH:
226 case TENSOR_CONTRACTION:
231 return view1_rank_change;
249 void setLocation(Kokkos::Array<int,7> location1, Kokkos::Array<int,7> location2)
253 Kokkos::Array<int,7> tensor_location = location1;
254 for (
unsigned d=0; d<rank_combination_types_.extent(0); d++)
256 switch (rank_combination_types_[d])
260 tensor_location[d] = location2[d] * view1_iterator_.
getExtent(d) + location1[d];
262 case DIMENSION_MATCH:
265 case TENSOR_CONTRACTION:
266 tensor_location[d] = 0;
270#ifdef HAVE_INTREPID2_DEBUG
272 for (
unsigned d=0; d<rank_combination_types_.extent(0); d++)
274 switch (rank_combination_types_[d])
279 case DIMENSION_MATCH:
280 case TENSOR_CONTRACTION:
290 tensor_view_iterator_.
setLocation(tensor_location);