JuliaLang / Compat.jl

Compatibility across Julia versions
Other
145 stars 117 forks source link

Poorman's 5-arg mul! #723

Closed oxinabox closed 3 years ago

oxinabox commented 3 years ago

This would close #681 It's very much a simplified stand-in. Doesn't get the same performance, but shouldn't be terrible (not that I have run benchmarks)

If people think that that is a bad idea then i can just drop this. Otherwise if people think its good, I can add tests and stuff to finish it off.

martinholters commented 3 years ago

Are there any realistic situations imaginable where people think "ah, this piece of code could well be replaced with a 5-arg-mul!" but the version in this PR is slower than whatever they had before? If no, I'd definitely be fine with this.

oxinabox commented 3 years ago

Are there any realistic situations imaginable where people think "ah, this piece of code could well be replaced with a 5-arg-mul!" but the version in this PR is slower than whatever they had before? If no, I'd definitely be fine with this.

If the alternative is them calling hand written GEMM calls then yes. e.g. I am wanting to replace this complex (and currently broken) code in Nabla https://github.com/invenia/Nabla.jl/blob/4cadc87677fb1187354999dcf93bd528f45f85d0/src/sensitivities/linalg/strided.jl#L25-L26 with 5-arg mul! calls, to simplify it. But I don't want to fully drop 1.0 support. (I am ok with it performing suboptimially)

oxinabox commented 3 years ago

Do you want to restrict A, B, C to AbstractVecOrMat or something like that, or split if there are ambiguities?

There won't be ambiguities since if not using 1.3+ there will be no other 5-arg mul! definitions

I duplicated the most generic signature that I found for 5 arg mul! in julia 1.5