I'm looking for a way to use JIT for the creator of Python class:
< Import from NMP as NMP in the form of NPP as the NPP, Automated by Time Import Time Class (object): @ win (float, float, float), target = "CPU") def __int __ (self) , X, y, z): self._x = x self._y = y self._z = z @autojit def runTest (self): n = 1000000 self. _z = 0 in xrange (n): self._z = self._z + np.sin (i) returns self._ if __name__ == '__main__': a = test (4,5,6) start_time = time ( ) Z = a.runTest () end_time = time () # Get printout of CPU time ("Math time: {0} s" .format (end_time - start_time)) print z However, it seems that I have to give a type for self
, which I do not know how to get it.
Maybe someone knows how to get it?
Thank you in advance - Andi
There was support for "jitting" classes Version 0.12 Removed from numba from:. This is called 'extension type', but nowadays all related examples do not work: TypeError: 'NotImplementedType' object is not callable
if executed with the current release (0.17).
So I suggest firmly that you take the runTest
functionality to your own function, and that you have the data in that function Use or pass, because those mechanisms are supported Otherwise, you are stuck in using the old versions of Amba.
class test: def __init __ (self, x, y, z): self.x = x self.y = y self.z = z @jit (float (float) )) Def runTest (z): n = 1000000 z = 0 in i xrange (n): z = z + np.sin (i) returns z if __name__ == '__main__': a = test (4,5,6) ) Start_time = time () z = runTest (az) end_time = time () # get printout of CPU time ("Math time: {0} s" .format (end_time) - start_time)) print z
< / Pre>
No comments:
Post a Comment