[Numpy-discussion] Calling C code that assumes SIMD aligned data.

Øystein Schønning-Johansen oysteijo at gmail.com
Thu May 5 05:38:51 EDT 2016


Hi!

I've written a little code of numpy code that does a neural network
feedforward calculation:

    def feedforward(self,x):
        for activation, w, b in zip( self.activations, self.weights,
self.biases ):
            x = activation( np.dot(w, x) + b)

This works fine when my activation functions are in Python, however I've
wrapped the activation functions from a C implementation that requires the
array to be memory aligned. (due to simd instructions in the C
implementation.) So I need the operation np.dot( w, x) + b to return a
ndarray where the data pointer is aligned. How can I do that? Is it
possible at all?

(BTW: the function works  correctly about 20% of the time I run it, and
else it segfaults on the simd instruction in the the C function)

Thanks,
-Øystein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160505/383ba64b/attachment.html>


More information about the NumPy-Discussion mailing list