Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
Cómo implementar un bucle for dentro de un combineKernel en GPU.js

Soy nuevo en gpu.js y necesito ayuda. Básicamente, quiero acceder a mis dos funciones del núcleo, pero no sé cómo sin sacrificar el gasto de llamar a createKernel cada vez. Sé que hay combineKernel, pero no he visto un ejemplo en el que use un bucle for adentro.

Así que tengo mi primera función que genera una matriz cuadrada a partir de un vector

 const functionA = gpu.createKernel(function(vector:number[]) { // just body of the code }).setOutput([somethingLength, somethingLength])

Luego, de la matriz cuadrada resultante, sumo cada una de sus columnas, y esto devuelve un vector. Así que tengo otra función para eso.

 const functionB = gpu.createKernel(function (squareMatrix: number[][], initialVector: number[]) { let sum = initialVector[this.thread.x] for (let i = 0; i < squareMatrixLength ; i++) { sum += squareMatrix[i][this.thread.x] } return sum; }).setOutput([initialVector.length])

También tengo un combineKernel para ambos.

 const functionC = gpu.combineKernels(functionA as any, functionB as any, function (initialVector: number[], vector: number[]) { return functionB(functionA(vector), initialVector) })

Ahora, tengo una cantidad de vectores que quiero someter a la función A y luego a la función B, quiero hacer algo como el siguiente código dentro de combineKernel para evitar el gasto de CPU a GPU, pero tengo problemas para resolverlo. Quiero que el resultado final sea una matriz 2D.

 for(let i=0; i<vectorsLength; i++){ newVector = functionB(functionA(vectors[i]), initialVector) } return newVector
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!