Closed JThobbyist closed 4 years ago
What's the error?
Anonymous functions may not work, try function sqre(x) {}
Thanks! It works as expected when it's a named function. Seems like a detail that might be good to note in the docs?
True. Mind opening an issue for that specifically?
Sure
(it me)
What is wrong?
I have tried and failed like a hundred times to figure out how to get even a simple custom function to work in a kernel. I've tried adding it to the kernel instance, and I've tried ading it to the gpu instance. Nothing works. Example Plz?
Where does it happen?
when trying to add any custom function in node.js on my surface pro 4 running windows 10 and the latest versions of node.js and GPU.js
How do we replicate the issue?
My code looks like:
` const _gpu = new GPU();
const sqre = function (x) {return (x)**2};
_gpu.addFunction(sqre, {argumentTypes: {x:'Number'}, returnType: 'Number'})
const seed = [1, 2, 3];
const kernel = _gpu.createKernel(function(a){ return sqre(a[this.thread.x]); }, { output: [3] });
const res = kernel(seed); console.log(res);`
I've also tried making the function a string, using addNativeFunction instead of addFunction, etc.
How important is this (1-5)?
5 (for me as a GPU.js beginner)
Expected behavior (i.e. solution)
the function sqre should have been accessible from within the kernel function
Other Comments