Invalid Parameter to Vectorize from example

Hello! I just got started with Mojo, been playing with in for the past 2 days. I run into an a syntax error from just copying the matmul example.
@mojo
from algorithm.functional import vectorize

fn matmul_tiled(inout C: Matrix, A: Matrix, B: Matrix):
@parameter
fn calc_row(m: Int):
@parameter
fn calc_tile[tile_x: Int, tile_y: Int](x: Int, y: Int):
for k in range(y, y + tile_y):

@parameter
fn dot[nelts: Int](n: Int):
C.store(
m,
n + x,
C.load[nelts](m, n + x)
+ A[m, k] * B.load[nelts](k, n + x),
)

vectorize[dot, nelts, size=tile_x]()

tile[calc_tile, tile_n, tile_k](C.cols, B.rows)

parallelize[calc_row](C.rows, C.rows)
@mojo
from algorithm.functional import vectorize

fn matmul_tiled(inout C: Matrix, A: Matrix, B: Matrix):
@parameter
fn calc_row(m: Int):
@parameter
fn calc_tile[tile_x: Int, tile_y: Int](x: Int, y: Int):
for k in range(y, y + tile_y):

@parameter
fn dot[nelts: Int](n: Int):
C.store(
m,
n + x,
C.load[nelts](m, n + x)
+ A[m, k] * B.load[nelts](k, n + x),
)

vectorize[dot, nelts, size=tile_x]()

tile[calc_tile, tile_n, tile_k](C.cols, B.rows)

parallelize[calc_row](C.rows, C.rows)
On this line vectorize[dot, nelts, size=tile_x]() I get the error : Cannot pass 'fn[Int](n = Int) capturing -> None' value, parameter expected 'Int'mojo
2 Replies
benny
benny7mo ago
this is funny timing, there was recently a big update that changed vectorize the docs need to be fixed, but for your code all you need to do is change
vectorize[dot, nelts, size=tile_x]()
vectorize[dot, nelts, size=tile_x]()
to
vectorize[nelts, dot, size=tile_x]()
vectorize[nelts, dot, size=tile_x]()
pascalpolygon
pascalpolygon7mo ago
Yeah I saw the email right after the post haha. Awesome, thanks
Want results from more Discord servers?
Add your server