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

Does NCNN support 3D convolution now? #3180

Closed
j71200 opened this issue Aug 18, 2021 · 1 comment
Closed

Does NCNN support 3D convolution now? #3180

j71200 opened this issue Aug 18, 2021 · 1 comment

Comments

@j71200
Copy link

j71200 commented Aug 18, 2021

error log | 日志或报错信息 | ログ

I know NCNN did not support 3D convolution in 2019. (#889)
But I still wanna give it a try.
At first, I have a PyTorch 3D convolution model.
PyTorch model -> ONNX model is fine
ONNX model -> simplified ONNX model is fine
simplified ONNX model -> NCNN model is fine (The model convertor did not show any error message like not support 3D convolution)
However, when I call
ncnn::Extractor ex = resnet3d.create_extractor();
an exception "Integer division by zero" popped out.

I wonder that is the exception due to NCNN does not support 3D convolution.
If NCNN does not support 3D convolution, will NCNN support 3D convolution in the near feature?

Thanks

model | 模型 | モデル

  1. https://github.com/kenshohara/3D-ResNets-PyTorch/blob/master/models/resnet.py

how to reproduce | 复现步骤 | 再現方法

  1. Use PyTorch 1.7.1 to convert PyTorch model to ONNX
  2. Use onnx-simplifier(0.3.4) to simplify ONNX model
  3. Use onnx2ncnn tool from NCNN(20200916) to convert ONNX to NCNN
  4. The code is shown below

ncnn::Net resnet3d;
resnet3d.load_param("resnet3Dmodel.param");
resnet3d.load_model("resnet3Dmodel.bin");

ncnn::Mat in = ncnn::Mat::from_pixels_resize(image.data, ncnn::Mat::PIXEL_BGR, image.cols, image.rows, image.cols, image.rows);
const float mean_vals[3] = { 0, 0, 0 };
const float norm_vals[3] = { 1.0 / 255, 1.0 / 255, 1.0 / 255 };
in.substract_mean_normalize(mean_vals, norm_vals);

ncnn::Mat out;
ncnn::Extractor ex = resnet3d.create_extractor();
ex.input("input", in);
ex.extract("output", out);

@nihui
Copy link
Member

nihui commented Dec 15, 2023

3d convolution is supported out of the box if you use pnnx tool to convert your fancy conv3d model to ncnn
https://github.com/pnnx/pnnx

@nihui nihui closed this as completed Dec 15, 2023
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