how to fill ITensor on NEIm2ColKernel.configure() ?
TensorShape shape(300, 300, 3); TensorShape shape_im2col(3*3, 298 * 298, 3);
output.allocator()->init(TensorInfo(shape_im2col, 1, DataType::F32));
input.allocator()->init(TensorInfo(shape, 1, DataType::F32));
input.allocator()->allocate();
//fill input buffer init
input.copy_from(const ITensor & src)
i
NEIm2ColKernel im2Col;
std::pair<unsigned int, unsigned int> pair(298, 298);
PadStrideInfo padStrdInfo(1, 1, 0, 0);
im2Col.configure(&input, &output, pair, padStrdInfo, false);
replace:
template
const Dtype* data_im copy to ITensor input.
Not sure I understand your question. Is it how to fill the input tensor?
In that case please have a look at the documentation: https://arm-software.github.io/ComputeLibrary/v17.04/index.xhtml#S4_6_4_working_with_objects Or this related issue: #28
yes, Is it how to fill the input tensor? Thanks! I can fill the input or output iTensor.
But , NEIm2ColKernel unable to obtain expected results . void Test_NEIm2ColFun() { printf("Test_NEIm2ColFun starting........\n"); NEIm2ColKernel neIm2Col; Tensor input; Tensor output; pair < unsigned int, unsigned int > convolved_dims; PadStrideInfo tPadStrideInfo; unsigned int batch=1, height=4, width=4;
auto *src_data = new char[height * width * batch];
auto *dst_data = new float[2*2 * 3 * 3*1];
for(unsigned int b = 0; b < batch; b++)
{
for(unsigned int h = 0; h < height; h++)
{
for(unsigned int w = 0; w < width; w++)
{
src_data[b * (width * height) + h * width + w] = static_cast<char>(w+h);
//printf("src_data[%d] = %s\n",b * (width * height) + h * width + w,src_data[b * (width * height) + h * width + w]);
}
}
}
printf("src_data[");
for(int i=0;i<16;i++)
{
printf("%d,",src_data[i]);
}
TensorShape shape(width, height, batch);
TensorShape shape_im2col(3*3, 2*2 , batch);
// Initialize the tensors dimensions and type:
output.allocator()->init(TensorInfo(shape_im2col, 1, DataType::F32));
input.allocator()->init(TensorInfo(shape, 1, DataType::F32));
// Allocate the input / output tensors:
input.allocator()->allocate();
output.allocator()->allocate();
//fill input buffer
Window input_window;
input_window.use_tensor_dimensions(input.info());
// Create an iterator:
Iterator input_it(&input, input_window);
// Except it works for an arbitrary number of dimensions
execute_window_loop(input_window, [&](const Coordinates & id)
{
std::cout << "Setting item [" << id.x() << "," << id.y() << "," << id.z() << "]";
*reinterpret_cast<float *>(input_it.ptr()) = src_data[id.z() * (width * height) + id.y() * width + id.x()];
std::cout << "value [" << (float)(src_data[id.z() * (width * height) + id.y() * width + id.x()])<< "]\n";
// printf("value[ %f ]\n", (src_data[id.z() * (width * height) + id.y() * width + id.x()]));
},
input_it);
NEIm2ColKernel im2Col;
std::pair<unsigned int, unsigned int> pair(2, 2);
PadStrideInfo padStrdInfo(1, 1, 0, 0);
im2Col.configure(&input, &output, pair, padStrdInfo, false);
im2Col.run(input_window);
// More efficient way: create an iterator to iterate through each row (instead of each element) of the output tensor:
Window output_window;
output_window.use_tensor_dimensions(output.info(), /* first_dimension =*/Window::DimY);
// Iterate through the rows (not each element) // Create an iterator: Iterator output_it(&output, output_window);
// Except it works for an arbitrary number of dimensions
execute_window_loop(output_window, [&](const Coordinates & id)
{
std::cout << "Copying one row starting from [" << id.x() << "," << id.y() << "," << id.z() << "]\n";
// Copy one whole row:
memcpy(dst_data + id.z() * (width * height) + id.y() * width, output_it.ptr(), width * sizeof(float));
},
output_it);
printf("dst_data[");
for(int j=0;j<36;j++)
{
printf("%d,",(int)dst_data[j]);
}
printf("]\n");
}
@AnthonyARM Is it the same bug? an error in the NEIm2ColKernel kernel (https://github.com/ARM-software/ComputeLibrary/blob/master/src/core/NEON/kernels/NEIm2ColKernel.cpp#L175).
Hello @jackdonghai can you have a look at issues #63 and #81 on how NEIm2Col can be used. Please let me know if you managed to get correct results.
Thank you very much. #81 Here's what I need .