(typingctx, data_ptr, shape_tup)
return signature(arr_typ, data_ptr, shape_tup), codegen
create an array from data_ptr with shape_tup as shape
create an array from data_ptr with shape_tup as shape
create an array from data_ptr with shape_tup as shape
def wrap_array(typingctx, data_ptr, shape_tup):
    """create an array from data_ptr with shape_tup as shape
    """
    assert isinstance(data_ptr, types.CPointer), "invalid data pointer"
    assert (isinstance(shape_tup, types.UniTuple)
            and shape_tup.dtype == np.intp), "invalid shape tuple"
    dtype = data_ptr.dtype
    arr_typ = types.Array(dtype, shape_tup.count, 'C')

    def codegen(context, builder, sig, args):
        assert(len(args) == 2)
        data = args[0]
        shape = args[1]
        # XXX: unnecessary allocation and copy, reuse data pointer
        shape_list = cgutils.unpack_tuple(builder, shape, shape.type.count)
        ary = _empty_nd_impl(context, builder, arr_typ, shape_list)
        cgutils.raw_memcpy(builder, ary.data, data, ary.nitems, ary.itemsize, align=1)

        # clean up image buffer
        fnty = lir.FunctionType(lir.VoidType(), [lir.IntType(8).as_pointer()])
        fn_release = cgutils.get_or_insert_function(builder.module, fnty, name="cv_delete_buf")
        builder.call(fn_release, [data])

        return impl_ret_new_ref(context, builder, sig.return_type, ary._getvalue())

        # # cgutils.printf(builder, "%d", shape)
        # retary = context.make_array(arr_typ)(context, builder)
        # itemsize = context.get_abi_sizeof(context.get_data_type(dtype))
        # shape_list = cgutils.unpack_tuple(builder, shape, shape.type.count)
        # strides = [context.get_constant(types.intp, itemsize)]
        # for dimension_size in reversed(shape_list[1:]):
        #     strides.append(builder.mul(strides[-1], dimension_size))
        # strides = tuple(reversed(strides))
        # #import pdb; pdb.set_trace()
        # context.populate_array(retary,
        #            data=data,
        #            shape=shape,
        #            strides=strides,
        #            itemsize=itemsize,
        #            meminfo=None)
        # return retary._getvalue()

    return signature(arr_typ, data_ptr, shape_tup), codegen
def wrap_array ( typingctx , data_ptr , shape_tup ) : assert isinstance ( data_ptr , types . CPointer ) , "invalid data pointer" assert ( isinstance ( shape_tup , types . UniTuple ) and shape_tup . dtype == np . intp ) , "invalid shape tuple" dtype = data_ptr . dtype arr_typ = types . Array ( dtype , shape_tup . count , 'C' ) def codegen ( context , builder , sig , args ) : assert ( len ( args ) == 2 ) data = args [ 0 ] shape = args [ 1 ] # XXX: unnecessary allocation and copy, reuse data pointer shape_list = cgutils . unpack_tuple ( builder , shape , shape . type . count ) ary = _empty_nd_impl ( context , builder , arr_typ , shape_list ) cgutils . raw_memcpy ( builder , ary . data , data , ary . nitems , ary . itemsize , align = 1 ) # clean up image buffer fnty = lir . FunctionType ( lir . VoidType ( ) , [ lir . IntType ( 8 ) . as_pointer ( ) ] ) fn_release = cgutils . get_or_insert_function ( builder . module , fnty , name = "cv_delete_buf" ) builder . call ( fn_release , [ data ] ) return impl_ret_new_ref ( context , builder , sig . return_type , ary . _getvalue ( ) ) # # cgutils.printf(builder, "%d", shape) # retary = context.make_array(arr_typ)(context, builder) # itemsize = context.get_abi_sizeof(context.get_data_type(dtype)) # shape_list = cgutils.unpack_tuple(builder, shape, shape.type.count) # strides = [context.get_constant(types.intp, itemsize)] # for dimension_size in reversed(shape_list[1:]): #     strides.append(builder.mul(strides[-1], dimension_size)) # strides = tuple(reversed(strides)) # #import pdb; pdb.set_trace() # context.populate_array(retary, #            data=data, #            shape=shape, #            strides=strides, #            itemsize=itemsize, #            meminfo=None) # return retary._getvalue() return signature ( arr_typ , data_ptr , shape_tup ) , codegen