-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python example in README doesn't work #248
Comments
Thank you very much for opening this issue @ForceBru ! This is indeed an error in the documentation, as the code has now been updated to use the util function instead of the internal dependency as per: Lines 4 to 7 in c4b3e6e
|
I've merged now the change - would you be able to test with the updated script? |
This says:
I just copied the code into import os
import kp
import numpy as np
def compile_source(source):
open("tmp_kp_shader.comp", "w").write(source)
os.system("glslangValidator -V tmp_kp_shader.comp -o tmp_kp_shader.comp.spv")
return open("tmp_kp_shader.comp.spv", "rb").read()
def kompute(shader):
# rest of the code ...and got this output:
The comments, however, say:
So, the output is different. Looks like the correct code should be calling
Then the output is:
Why isn't the |
Yes that is correct, it's not part of the API, it's only used in the tests. This shouldn't be a blocker as if you do want to perform online compilation of shaders you can use https://github.com/realitix/pyshaderc. For completeness, this was removed in v0.8.0 as the functionality was very much just for tests and was adding a lot of complexity via the glslang dependency #235 |
Ah, so Kompute doesn't compile shaders, and one should be using either |
That is correct - there's actually some documentation, but may be worth actually extending - I'll add this to have explicitly covered https://kompute.cc/overview/shaders-to-headers.html |
By the way, this is still an issue with the Python Example here:
And still, the above problem with the wrong output is also present:
Changing it to
|
Your first Kompute (Python) says:
AttributeError: module 'kp' has no attribute 'Shader'
.Code
The code is the same as in the README - I just imported
kp
andnumpy as np
on top. (BTW, it would be nice to be able to copy & paste this code and immediately run it, without adding the imports)Running the code
Side note:
terminating with uncaught exception of type pybind11::error_already_set
is probably a bug.A comment in the code says
See documentation shader section for compile_source
, but I couldn't find this section. Furthermore, the documentation doesn't listShader
under Core Python components. The only documentation entry that mentions thecompile_source
function is this code, which just saysspirv = compile_source(shader)
and goes on assuming that the user knows whatcompile_source
is.I found a function called
compile_source
in the tests:kompute/python/test/utils.py
Lines 4 to 7 in c4b3e6e
Is this the function I should be using here?
Versions
kp
0.8.0The text was updated successfully, but these errors were encountered: