inducer / compyte Goto Github PK
View Code? Open in Web Editor NEWA common set of compute primitives for PyCUDA and PyOpenCL
A common set of compute primitives for PyCUDA and PyOpenCL
Move all dependency to Theano fil scalar/basic.py and copy this file here.
Mark clearly that this file is under BSD 3 clauses
First version, copy Theano reshape
2e version optimize it by not always coping when not contiguous when the strides/shapes allow it.
In the commit 2293b43 a test for numpy.lib.stride_tricks.as_strided()
was added in array.py
checking that it preserves a structured dtype
. It works for the rather simple type there, but stops working for types with padding set through offsets
parameter:
import numpy
from numpy.lib.stride_tricks import as_strided
dtype = numpy.dtype({
'names':['i1','nested','i2'],
'formats':['<u4',[('v', '<u8')],'<u4'],
'offsets':[0,8,16], 'itemsize':24})
arr = numpy.zeros((128,), dtype)
print(dtype)
print(new_arr.dtype)
Output:
{'names':['i1','nested','i2'], 'formats':['<u4',[('v', '<u8')],'<u4'], 'offsets':[0,8,16], 'itemsize':24}
[('i1', '<u4'), ('f1', 'V4'), ('nested', [('v', '<u8')]), ('i2', '<u4'), ('f4', 'V4')]
Apparently, as_strided()
adds some dummy fields in this case and removes offsets
. The alternative version of as_strided()
in array.py
does preserve them, but since the numpy
one passes the test, it does not get invoked.
Is it the planned behavior?
If we add 3 tensor and 2 of them are c contiguous but not the last, it seam wasteful to compute the index 2 times for each c contiguous array.
I'm not sure how much difference it makes in practice, but the char
type in C/C++ isn't guaranteed to be signed or unsigned.
By default, x86/M1 seem to treat char as signed, but ppc64le treats it as unsigned. This can also be modified by compiler options (e.g., https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/C-Dialect-Options.html#index-funsigned-char).
Line 122 in d4549d4
OpenCL seems to define it as signed: https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html#built-in-scalar-data-types
This include:
Copy/adapt the theano code for dimshuffles.
I'm getting a deprecation warning from this line with numpy-1.20 saying that np.bool
is just an alias for the builtin bool type. Is changing this likely to break or cause some awful performance regression on older numpy versions?
Is this library deprecated in favor of libgpuarray?
This was causing problem on Windows I think.
There is 42 of them:
char1, uchar1, char2, uchar2, char3, uchar3,
char4, uchar4, short1, ushort1, short2, ushort2,
short3, ushort3, short4, ushort4, int1, uint1, int2,
uint2, int3, uint3, int4, uint4, long1, ulong1,
long2, ulong2, long3, ulong3, long4, ulong4,
longlong1, ulonglong1, longlong2, ulonglong2,
float1, float2, float3, float4, double1, double2
There is 2 way to implement them: add basic typenum as for other basic dtype or use a system like numpy composite dtype. I'm not sure what is best.
As pointed out by @seberg in #36 (comment).
This is needed for OpenCL (since the current code does something really hacky).
Also might help support multiple CUDA contexts.
To don't use this field by mistake in old code that don't support strides.
We need PyCUDA/PyOpenCL to try to use the .bytes fields when we ask him to do so.
We could use PyOpenCL w
http://documen.tician.de/pyopencl/array.html#complex-numbers
In addition, I've added a rudimentary facility for translating Fortran
kernels to OpenCL, see here:
https://github.com/inducer/pyopencl/tree/master/contrib/fortran-to-opencl
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.