Skip to content
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

Uncaught Error: argument bit ratio not found #600

Open
peakpoint opened this issue Apr 9, 2020 · 6 comments · May be fixed by #731
Open

Uncaught Error: argument bit ratio not found #600

peakpoint opened this issue Apr 9, 2020 · 6 comments · May be fixed by #731

Comments

@peakpoint
Copy link

What is wrong?

Adding certain custom functions causes the error: Uncaught Error: argument bit ratio not found

Where does it happen?

Not system specific

How do we replicate the issue?

<script>
const gpu = new GPU()

gpu.addFunction(function f(x, y) {
    return y[0]
})

const test = gpu.createKernel(function (a) {
    f(1, a)
}).setOutput([4, 4]).setGraphical(true)

test([0])
</script>

Setting setGraphical(true) causes the error for some reason

How important is this (1-5)?

3 or 4 maybe?

Expected behavior (i.e. solution)

No error

Other Comments

In FunctionBuilder.assignArgumentBitRatio, replacing calleeNode.argumentBitRatios[i] with calleeNode.argumentBitRatios[argumentIndex] should fix the problem.

Also, why does having a blank return statement cause an error

const test = gpu.createKernel(function () {
    // stuff
    return
}).setOutput([4, 4]).setGraphical(true)
test() // Uncaught Error: Unexpected return statement on ...

when there is no error with having no return statements

const test = gpu.createKernel(function () {
    // stuff
}).setOutput([4, 4]).setGraphical(true)
test()
@harshkhandeparkar
Copy link

When you are using setGraphical(true), you need to do a this.color(r, g, b, a) as the output and not return a number as a value.

@robertleeplummerjr
Copy link
Member

We need to throw more descriptive errors here.

@robertleeplummerjr
Copy link
Member

The problem is that you aren't passing in the second variable, y that you are referencing, and there somehow the logical checks for that weren't handled early enough.

@peakpoint
Copy link
Author

What do you mean by "you aren't passing in the second variable"?

@robertleeplummerjr
Copy link
Member

I think I misspoke, I haven't had time to properly look into this.

@mweitzel
Copy link

mweitzel commented May 25, 2020

I'm experiencing this as well, when I pass an array more than a single function call from the kernel.

addFunction(foo(array) {
  return [array[0], array[1]]
})
addFunction(bar(array) {
  return foo(array)
})
k = createKernal(function(array) {
  foo(array) // totally fine
  bar(array) // errs with "gpu-browser.js:6923 Uncaught Error: Bit ratio for argument objList not found in function bar"
})
k([1,2,3,4,5])

exebetche added a commit to exebetche/gpu.js that referenced this issue Dec 2, 2021
In "assignArgumentBitRatio" the index for "argumentBitRatios" should be the one of the function, not the kernel. Otherwise, you get a "bit ratio not found" error if you pass arguments to a function with a different order than they're passed to the kernel.
Fix gpujs#600
@exebetche exebetche linked a pull request Dec 2, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants