ncnn Why is my 1D convolution not working?

drkbr07n  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(66)

Why is my 1D convolution implementation not working?

The output shape comes out to 0x0x0.

Also where is the C API documenation?

More info:
I am linking against the arm64-v8a version for an android device with a qualcomm soc.

Secondary question

How do I get max performance for a 1d convolution. Where's the implementation for that max performance conv?

#include <iostream>
#include "ncnn/cpu.h"
#include "ncnn/net.h"
#include "ncnn/layer.h"

int main() {
	int input_length = 1 << 16;
	int kernel_length = 4;

	ncnn::Mat input(input_length);
	ncnn::Mat kernel(kernel_length);
	std::cout << input.h << ' ' << input.w << ' ' << input.c << std::endl;
	std::cout << kernel.h << ' ' << kernel.w << ' ' << kernel.c << std::endl;
	ncnn::Mat output;

	ncnn::Option opt;
	opt.num_threads = 1;

	ncnn::Layer* conv1d = ncnn::create_layer(81);

	ncnn::ParamDict pd;
	pd.set(0, 1);
	pd.set(1, 1);
	pd.set(2, 1);
	pd.set(3, 0);
	pd.set(4, (float)(kernel.w));

	conv1d->load_param(pd);
	conv1d->load_model(ncnn::ModelBinFromMatArray(&kernel));

	conv1d->create_pipeline(opt);

	conv1d->forward(input, output, opt);
	
	conv1d->destroy_pipeline(opt);
	
	delete conv1d;
	
	std::cout << "Output shape: " << output.w << " x " << output.h << " x " << output.c << std::endl;
}

相关问题