Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run just a raw tensor through ncnn? I'm getting "incompatible constructor arguments" #9

Open
redthing1 opened this issue Jul 30, 2023 · 1 comment

Comments

@redthing1
Copy link

Hello,

I want to pass a raw array/tensor to my model. My model works fine in onnxruntime, wonnx, etc. I want to run it in ncnn:

Tencent#3447

Here is where they said you can do it as such:

float* data_ptr;
Mat in(data_length, data_ptr);

using this constructor:

// external vec
Mat(int w, void* data, size_t elemsize = 4u, Allocator* allocator = 0);

However, I'm trying to do this in python:

input_mat = ncnn.Mat(flat_input_value.shape[0], flat_input_value)

But I get this:

failed to execute ncnn: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. ncnn_vulkan.ncnn.Mat()
    2. ncnn_vulkan.ncnn.Mat(shape: tuple, *, elemsize: int = 4, elempack: int = 1, allocator: ncnn_vulkan.ncnn.Allocator = None)
    3. ncnn_vulkan.ncnn.Mat(w: int, *, elemsize: int = 4, elempack: int = 1, allocator: ncnn_vulkan.ncnn.Allocator = None)
    4. ncnn_vulkan.ncnn.Mat(w: int, h: int, *, elemsize: int = 4, elempack: int = 1, allocator: ncnn_vulkan.ncnn.Allocator = None)
    5. ncnn_vulkan.ncnn.Mat(w: int, h: int, c: int, *, elemsize: int = 4, elempack: int = 1, allocator: ncnn_vulkan.ncnn.Allocator = None)
    6. ncnn_vulkan.ncnn.Mat(w: int, h: int, d: int, c: int, *, elemsize: int = 4, elempack: int = 1, allocator: ncnn_vulkan.ncnn.Allocator = None)
    7. ncnn_vulkan.ncnn.Mat(m: ncnn_vulkan.ncnn.Mat)
    8. ncnn_vulkan.ncnn.Mat(array: buffer)

Invoked with: 150528, array([104.32   , 129.22101, 151.061  , ..., -85.68   , -83.779  ,
       -82.939  ], dtype=float32)
[1]

Any idea how I can do this kind of constructor from Python?

@joeyballentine
Copy link
Owner

Hey, sorry for the late response on this, but the official ncnn package now supports Vulkan in the python bindings apparently, so I'd recommend switching to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants