<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div style="font-size:12.800000190734863px" class=""><br class=""></div><div style="font-size:12.800000190734863px" class="">Well I was rather thinking of making a Swift-only library (at least at first) but that would also be available for other platforms e.g Linux or maybe some day on Windows =&gt; also working with reduced performance without the Accelerator Framework but leveraging it on Apple Platforms (and possibly leveraging others on the other platforms). This said I am open to discussion on this... but having a very nice syntax for swift and having an close to one-to-one equivalent also for Objective-C will probably add quite some difficulties.</div><div style="font-size:12.800000190734863px" class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>While still very much in its infancy, just to add the libraries out there, there is:&nbsp;<a href="https://github.com/abeschneider/stem" class="">https://github.com/abeschneider/stem</a>&nbsp;. However, the library currently suffers from design issues related to dispatching correctly from generic functions. That said, I was able to recreate a large part of the Numpy functionality while allowing the ability to leverage the Accelerator Framework and OpenCL/CUDA.</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div style="font-size:12.800000190734863px" class="">&gt; again, with the obvious implementation, this wastes space for temporaries and results in extraneous passes through the data. It is often *possible* to solve these issues (at least for some the most common cases) by producing proxy objects that can fuse loops, but that gets very messy very fast, and it’s ton of work to support all the interesting cases.</div><div style="font-size:12.800000190734863px" class=""><br class=""></div><div style="font-size:12.800000190734863px" class="">This is clear to me and to be honest with you I am not really sure of the best strategy to make this.&nbsp;</div></div></blockquote><div><br class=""></div><div>The most successful method I’ve seen for dealing with this is let the user write what is most natural first (allowing for temporaries) but provide a path to optimize (using in-place operations). While expression trees can automate this for the user, it also has the potential for being much more difficult to debug and may not be as optimal as a hand-crafted expression.</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div style="font-size:12.800000190734863px" class=""><br class=""></div><div style="font-size:12.800000190734863px" class=""><div class="">I don't think that the primary target for the library should be to deliver the highest performance possible.</div><div class="">&nbsp; =&gt; People who do need that level of performance would still need to analyze and optimize their code by themselves and/or directly call the Acceleration Framework or other specialized libraries.</div><div class=""><br class=""></div><div class="">What I would like to reach instead is rather what I would call "the highest usability possible with decent performance". Some programmers will be satisfied with the level of performance and will enjoy the readability and maintainability of the code based of the library, whereas other will go for more performant libraries (and that is perfectly fine!). Actually, I would even expect later that some of those who belong to the latter category will start experimenting with the easy but less performant library (lets call it here "easy maths library") and optimize their code based on a high performance library only in a second step.</div></div></div></blockquote><div><br class=""></div><div>If you can define your operations at the right granularity you can write really optimized Accelerate/OpenCL/CUDA code for the low level parts and string it together with less optimize code.</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div style="font-size:12.800000190734863px" class=""><br class=""></div><div style="font-size:12.800000190734863px" class="">My idea of a possibly pragmatic roadmap (which can be followed in that order) to make such a library almost from scratch with the long-term goal of being quite performant but primarily very easy to use could be:</div><div style="font-size:12.800000190734863px" class=""><br class=""></div><div style="font-size:12.800000190734863px" class="">1) think about the integration to the language, the syntax, the high-level user documentation, etc. and demonstrate all this based on a relatively low performance implementation</div><div style="font-size:12.800000190734863px" class=""><br class=""></div><div style="font-size:12.800000190734863px" class="">2) generate a collection a typical operations where the low-level libraries offer very nice performance or where a clever handling of the temporary variables is possible</div></div></blockquote><div><br class=""></div><div>For (1) and (2), it’s worth taking a look at what libraries exist already. People have spent a lot of time organizing and re-organizing these. While not perfect, Numpy has become one of the most successful matrix libraries out there.</div><br class=""></div><br class=""></body></html>