XLA: linear algebra library for TensorFlow
developers.googleblog.com
developers.googleblog.com
No, it can not be implemented this way, it is numerically unstable, and will produce NaNs if any input is greater than ~88.7. Luckily, it is also not how its implemented in Tensorflow: https://github.com/tensorflow/tensorflow/blob/2c8d0dca978a24...
For a clean (and more efficient) C version of this algorithm, take a look at NNPACK reference implementation: https://github.com/Maratyszcza/NNPACK/blob/master/src/ref/so...
https://github.com/tensorflow/tensorflow/blob/2c8d0dca978a24...
https://github.com/tensorflow/tensorflow/blob/2c8d0dca978a24...
Chalk it up to poetic license? ;-)
Optimized implementation is in assembly (PeachPy). See https://github.com/Maratyszcza/NNPACK/blob/master/src/x86_64... for the vectorized expf
[1]: https://github.com/Maratyszcza/NNPACK/blob/master/src/x86_64...
void softmax1(int n, const float *x, float *y)
{
int i;
float s, max = -FLT_MAX;
for (i = 0; i < n; ++i) max = max > x[i]? max : x[i];
for (i = 0, s = 0.0f; i < n; ++i) s += (y[i] = expf(x[i] - max));
for (i = 0, s = 1.0f / s; i < n; ++i) y[i] *= s;
}
This micro benchmark proves my point: using expf from libm, the reference implementation in nnpack is suboptimal. It is possible that a vectorized expf may change the fact, but the developer needs to prove it with numbers.If you need to install TensorFlow on Windows 10 you can follow this
pip3 install [filename]
...until everything was installed. I gotta buy that man more than a few beers for all the time he's saved me over the years. Bonus points: got the wheels with Intel MKL and OpenCV+contrib.So, why is TF slower?
If you're looking for more detailed information that's missing from the docs, please do file a Github issue about it. Thanks!
For CPU, mobile code footprint reduction was the driving force.
Trying to understand: you don't want to ship a compiler library on principle, or is it some kind of product requirement, or ? There's lots of cool work to be done in the compiler space so use cases help to prioritize. :-) Thanks!