ToT: conj() on nested-tile contractions; real-plain x complex-ToT products via one real gemm - #574
Draft
kshitij-05 wants to merge 1 commit into
Conversation
…ducts via one real gemm conj(A * B) on tensor-of-tensor operands did not compile: ContEngine's per-cell multiply-add ops static_cast the ComplexConjugate<void> contraction factor to the element type, Tensor::gemm forwarded it as the BLAS alpha, the ContractReduce<..., ComplexConjugate<...>> specializations named their result type through a value-returning gemm nested tiles do not have, and their nested-tile accumulate was an abort() stub. - detail::elem_factor<Numeric>(factor): the per-element multiplier for a contraction factor -- the factor for numeric factors, 1 for ComplexConjugate<...> (conjugation and scale are applied to the finished result by ContractReduce's finalization, as for non-nested tiles); used by the ToT per-cell ops in ContEngine and by Tensor::gemm's alpha - ContractReduce ComplexConjugate specializations: result_type is Result; the nested-tile accumulate and the arena-aware partial-result reduce are shared with the primary template (ContractReduceBase::accumulate_nested / reduce_results) - ToT x real plain-tensor products: when the plain element type is the real part of the inner element type, the complex slabs are viewed as real matrices with the inner extent doubled (re,im interleaved) and the strided GEMM fast path runs in real arithmetic with alpha = beta = 1 - tests: tot_conj suite in tot_expressions.cpp -- conj(a), permuted conj(a), conj(a)*b, a*conj(b), conj(a*b), conj(a)*b with an inner contraction, and the mixed-type ToT x real-plain product, against explicit references
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #573 (branch
kshitij/feature/strided-tot-kernels-complex); to be retargeted tomasteronce #573 is merged.Problem
conj()on a ToT contraction does not compile.conj(A * B)carries aComplexConjugate<void>contraction factor; the ToT per-cell multiply-add ops inContEnginestatic_castthat factor to the element type,Tensor::gemmforwards it as the BLAS alpha, and theContractReduce<…, ComplexConjugate<…>>specializations name their result type through a value-returninggemmthat nested tiles do not have.A("i,j;a") * t("j,k"),Tensor<Tensor<complex<double>>>×Tensor<double>) skips the ToT × plain-tensor GEMM fast path, which requires identical element types, and runs the per-cell AXPY loop.Changes
detail::elem_factor<Numeric>(factor): the per-element multiplier for a contraction factor — the factor for numeric factors,1forComplexConjugate<…>(conjugation and scale are applied to the finished result byContractReduce's finalization, as for non-nested tiles). Used by the ToT per-cell ops inContEngineand byTensor::gemm's alpha.ContractReduce<…, ComplexConjugate<void>>/<…, ComplexConjugate<Scalar>>:result_typeisResult, as in the primary template, and the nested-tile accumulate (which was anabort(); // not yet implementedstub) and the partial-result reduce are shared with the primary template throughContractReduceBase::accumulate_nested/reduce_results.tot_conjsuite intests/tot_expressions.cpp, real and complex rows):conj(a), permutedconj(a),conj(a) * b,a * conj(b),conj(a * b)(outer contraction with inner outer product),conj(a) * bwith an inner contraction, and the mixed-type ToT × real-plain product, all against explicit references.Testing
arena_strided_dgemm,einsum*,tot_expressions(incl.tot_conj),tot_dist_array_part{1,2}: 821 cases, no errors.Not addressed