How to change vector dialect to memref dialect?

    %c0 = arith.constant 0 : index
    %cst = arith.constant 0.000000e+00 : f32

    %0 = arith.constant dense<[[0.0470522791, -0.0496789068, 0.0150767975, 0.3661201, -0.377589107]]> : vector<1x5xf32>
    %1 = arith.constant dense<0.298596174> : vector<1xf32>
    // below is my code. 
    // %10 = memref.view %0[] : vector<1x5xf32> to memref<1x5xf32>

here i use vector dialect only for initialize. And any simple method for initialize? Or change vector dialect to memref dialect for following memref.load?

The memref dialect represents memory. If you want to have something in memory you can either store something into it or create a global value. You cannot “initialize” memory to arbitrary values.

The vector dialect represents (a generalization of) hardware vectors. You can create a constant value of vector type and use where a vector is expected, which is roughly equivalent to a hardware instruction taking an immediate value.

You cannot just convert a vector to memref because they live in different conceptual spaces: registers vs. vectors. However, you can store the contents of a vector into a memref, e.g., by using vector.transfer_write.

Thank your for your reply. For now I use script to store value to memref like

for a in range(8):
    for b in range(1):
        for c in range(5):
            for d in range(5):
                f.write(f"    %conv28_{a}{b}{c}{d}_a = arith.constant {a} : index\n")
                f.write(f"    %conv28_{a}{b}{c}{d}_b = arith.constant {b} : index\n")
                f.write(f"    %conv28_{a}{b}{c}{d}_c = arith.constant {c} : index\n")
                f.write(f"    %conv28_{a}{b}{c}{d}_d = arith.constant {d} : index\n")
                f.write(f"    %conv28_{a}{b}{c}{d}_v = arith.constant {conv28_weights[a, b, c,d]} : f32\n")
                f.write(f"    memref.store %conv28_{a}{b}{c}{d}_v, %0[%conv28_{a}{b}{c}{d}_a, %conv28_{a}{b}{c}{d}_b, %conv28_{a}{b}{c}{d}_c, %conv28_{a}{b}{c}{d}_d] : memref<8x1x5x5xf32> \n")

And the generated file is so big. So I want a simple method for storing value to memref. I try global now.

It looks like you need a global constant. Those exist.

Also consider using Python bindings instead of string stitching the IR.