ModularM
Modular3y ago
1 reply
aetherclouds

Cannot create a `DTypePointer` from `pointer<scalar<...>>`

how do I cast a pointer (btw, what is this? a MLIR type?) to a Pointer or preferably a DTypePointer? Inspired by this code,
 out_arr.data = DTypePointer[dtype](
            __mlir_op.`pop.index_to_pointer`[
                _type : __mlir_type[`!kgen.pointer<scalar<f32>>`]
            ](
                SIMD[DType.index, 1](
                    in_arr_f32.__array_interface__["data"][0].__index__()
                ).value
            )
        )

(where in_arr_f32 is a numpy ndarray)
but I get
Included from /home/prj/mojo/mojo-array/test.mojo:3:
/home/prj/mojo/array2d.mojo:784:44: error: cannot construct 'DTypePointer[dtype]' from 'pointer<scalar<f32>>' value in assignment
        out_arr.data =  DTypePointer[dtype](
                        ~~~~~~~~~~~~~~~~~~~^
/root/.modular/pkg/packages.modular.com_mojo/bin/mojo: error: failed to parse the provided Mojo

should be fine according to docs?
image.png
Was this page helpful?