0

I want to transpose a Halide::Buffer.Is there a way to do it?

I have tried transpose() in Halide. But it shows error.

    Halide::Func B;
    Halide::Var x, y, c; 
    B(x, y, c)= 0.0f;
    B(0,0,c)=  1.0f; B(1,0,c)= 0.0f; B(2,0,c)= 0.0f; 
    B(0,1,c)=  1.0f; B(1,1,c)= 2.0f; B(2,1,c)= 0.0f; 
    B(0,2,c)=  1.0f; B(1,2,c)= 2.0f; B(2,2,c)= 3.0f;

    Halide::Buffer<float> B_mat = B.realize(6, 6, 1);

    Halide::Buffer<float> C_mat = B_mat.transposed(0,1);

error: conversion from ‘void’ to non-scalar type ‘Halide::Buffer’ requested Halide::Buffer C_mat = B_mat.transpose(0,1);

1 Answers1

0

It seems as if there is a mismatch between the code you posted and your errer message. Your error message states that you have used transpose(0, 1), this doesn't return a Halide::Buffer<float>:

void transpose(int d1, int d2)

You should take a alook at the documentation of transpose and transposed and use

Buffer<T, D> transposed(int d1, int d2)

instead.

geoidiot
  • 107
  • 2
  • 12
  • Hi, Thanks for your reply! The last line was "Halide::Buffer C_mat = B_mat.transpose(0,1);" You are right. I understand "B_mat.transpose(0,1)" returns void. But, wondering how to correct it. Reading the Halide document, it is not clear to me. Would you please explain how to use "Buffer transposed(int d1, int d2)" in correct way! That would be a great help! – Nusrat Jemy Sep 10 '19 at 10:33
  • BufferC_mat = B_mat.transposed(0,1); gives error message: ‘class Halide::Buffer’ has no member named ‘transposed’; did you mean ‘transpose’? BufferC_mat = B_mat.transposed(0,1); – Nusrat Jemy Sep 10 '19 at 10:43
  • Try using Halide::Runtime::Buffer instead Halide::Buffer – geoidiot Sep 10 '19 at 11:02
  • I have fihured it out. it will be: "B_mat.transpose(0,1);" then the index of B_mat will be reversed! – Nusrat Jemy Sep 10 '19 at 13:56