Coder Social home page Coder Social logo

Comments (4)

inducer avatar inducer commented on June 2, 2024

Thanks for the report. How does https://gitlab.tiker.net/inducer/pyopencl/-/merge_requests/138 look?

from pyopencl.

beatreichenbach avatar beatreichenbach commented on June 2, 2024

Thank you for such a quick reply!

Just by looking at the code it seems like that makes sense as that's my understanding from reading the OpenCL docs.

I haven't tested those use cases but should image2d_array -> Buffer and more importantly image2d_array -> image2d_array also be supported?

from pyopencl.

inducer avatar inducer commented on June 2, 2024

Good catch. See updated https://gitlab.tiker.net/inducer/pyopencl/-/merge_requests/138.

from pyopencl.

beatreichenbach avatar beatreichenbach commented on June 2, 2024

Yep, I just did a super quick test to see if image->buffer and image->image actually works and seemed to be okay.
Thanks for the quick fix :)

import pyopencl as cl
import pyopencl._cl as _cl
import numpy as np

context = cl.create_some_context(interactive=False)
queue = cl.CommandQueue(context)

image_format = cl.ImageFormat(cl.channel_order.RGBA, cl.channel_type.FLOAT)
image = np.ascontiguousarray(np.zeros((128, 128, 4), np.float32))
image_shape = (image.shape[1], image.shape[0])
array_shape = (*image_shape, 1)
image_cl = cl.Image(context, cl.mem_flags.READ_ONLY, image_format, shape=image_shape)
image_array_cl = cl.Image(context, cl.mem_flags.READ_ONLY, image_format, shape=array_shape, is_array=True)
image2_array_cl = cl.Image(context, cl.mem_flags.WRITE_ONLY, image_format, shape=array_shape, is_array=True)
buffer_cl = cl.Buffer(context, cl.mem_flags.WRITE_ONLY, size=image.nbytes)

_cl._enqueue_copy_image(queue, src=image_array_cl, dest=image2_array_cl, src_origin=(0, 0, 0), dest_origin=(0, 0, 0), region=array_shape)
_cl._enqueue_copy_image_to_buffer(queue, src=image_array_cl, dest=buffer_cl, offset=0, origin=(0, 0, 0), region=array_shape)

from pyopencl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.