Thanks for the pointer.  This is what we've generalized out of that:

def numpy3d_to_array(np_array, order=None):
    import pycuda.autoinit
    from pycuda.driver import Array, ArrayDescriptor3D, Memcpy3D,
dtype_to_array_format

    if order is None:
        order = 'C' if np_array.strides[0] > np_array.strides[2] else 'F'

    if order.upper() == 'C':
        d, h, w = np_array.shape
    elif order.upper() == "F":
        w, h, d = np_array.shape
    else:
        raise LogicError, "order must be either F or C"

    descr = ArrayDescriptor3D()
    descr.width = w
    descr.height = h
    descr.depth = d
    descr.format = dtype_to_array_format(np_array.dtype)
    descr.num_channels = 1
    descr.flags = 0

    device_array = Array(descr)

    copy = Memcpy3D()
    copy.set_src_host(np_array)
    copy.set_dst_array(device_array)
    copy.width_in_bytes = copy.src_pitch = np_array.strides[1]
    copy.src_height = copy.height = h
    copy.depth = d

    copy()

    return device_array

Is this something that we could submit a patch with?  Seems like it
could be useful in the pycuda lib.

Cheers,
Eli

On Tue, Jul 12, 2011 at 7:22 PM, Andreas Kloeckner
<[email protected]> wrote:
> On Tue, 12 Jul 2011 19:06:52 -0700, Eli Stevens (Gmail) wrote:
>>
>> Followup:
>>
>> What is class pycuda.driver.Memcpy3D.src_height supposed to be set to?
>>  I can't seem to find a valid value.
>
> See test_3d_texture() in test/test_wrapper.py.
>
> Andreas
>
> _______________________________________________
> PyCUDA mailing list
> [email protected]
> http://lists.tiker.net/listinfo/pycuda
>

_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda

Reply via email to