4 ms·
It is so bad, that in julia functions are not first class. Instead, I would love to use scala 3 for machine learning since this is the perfect type system for s
by zeec123 5y ago
It is so bad, that in julia functions are not first class.
Instead, I would love to use scala 3 for machine learning since this is the perfect type system for such a task, but linear algebra support is not good enough.
- kinjba11 5y agoWhat do you mean by "not first class"? https://docs.julialang.org/en/v1/manual/functions/#man-anonymous-functions https://docs.julialang.org/en/v1/manual/functions/#man-anony...
- zeec123 5y agoIt means I cannot fully specify the type of function my interface expects as an argument. A function is of type ‘Function’. There is no way to define it with the type of its argument or the type of what it returns.
- eigenspace 5y agoActually, Julia functions are all subtypes of Function. Every julia function has a unique type. We don't parameterize a function by it's input and return types because functions are extremely polymorphic in julia. However, there's lots of tricks one can do to dispatch on whether or not a given function have methods that satisfy some sort of interface, see here: https://github.com/oxinabox/Tricks.jl#we-can-use-static_hasmethod-to-declare-traits https://github.com/oxinabox/Tricks.jl#we-can-use-static_hasm... Using this technique, you can do compile time dispatch on things like input and return types.
- saiojd 5y agoFunctions are polymorphic in many languages that let you annotate the their types. The concern is not really for dispatch here, it's for readability/correctness.
- eigenspace 5y ago> The concern is not really for dispatch here, it's for readability/correctness. Then dispatch to an error.
- emergentorder 5y agoCheck out my project NDScala (https://github.com/SciScala/NDScala https://github.com/SciScala/NDScala). N-dimensional arrays in Scala 3. Think NumPy ndarray, but with compile-time type-checking/inference over shapes, ndarray/axis labels & numeric data types.
- zeec123 5y agoThanks. Does it map to native routines like numpy? If yes, what about the copy overhead from JVM to native memory?
- The_rationalist 5y agoNd4j (another project) enable to use cuda/MKL sota backends. It does native calls but I don't think the overhead is high. Besides some of those overhead are being optimized in the JNI successor.
- emergentorder 5y agoYes, it uses ONNX Runtime / MLAS (their native BLAS lib) under the hood. And yes, there is copy overhead but you can eliminate it internally to a single function/graph by compiling it down to a single ONNX model. The end result is within ~15% run time of PyTorch w/ MKL when training a reasonably-sized MLP. And ORT also provides support for CUDA and a number of other "execution providers".