0

I am a new guy trying Halide programming. I met an issue when porting some Halide code into Android via Halide::Generator. Below is my code:

#include "Halide.h"
using namespace Halide;
using namespace Halide::ConciseCasts;
using namespace std;
Func align_layer(int i) {
    Func ret;
    Var x, y;

    ret(x, y) = i;

    return ret;
}

class TestGenerator : public Halide::Generator<TestGenerator> 
{
    public:
    Input<uint16_t> value{"value"};

    // We then define a method that constructs and return the Halide
    // pipeline:
    void generate() 
    {
        int test = value;
    }
};

HALIDE_REGISTER_GENERATOR(TestGenerator, test_generator)

When I compile it, I got below error:

generator_test.cpp:31:14: error: cannot convert ‘Halide::Internal::GeneratorBase::Input {aka Halide::GeneratorInput}’ to ‘int’ in initialization int test = value;

I did some try: int test = (int)(value); or use case converting, all did not work.

Could any one give me a hand?

Aksen P
  • 4,564
  • 3
  • 14
  • 27
walter
  • 11
  • 2
  • Off-topic: About [using namespace std](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) – same applies for other namespaces, and the more you import, the greater the risk of name clashes... – Aconcagua Oct 26 '19 at 05:03
  • 1
    Have you peaked into [documentation](https://halide-lang.org/docs/namespace_halide.html)? Have you had a look at the [tutorials](https://halide-lang.org/tutorials/tutorial_introduction.html)? I did so, just to notice that this isn't intended usage... Seeing what you try to do I think you started far to early with generators. Recommendation: Work through the more basic tutorials to learn what you actually can do with the elements defined in Halide before you move to more advanced concepts like generators. – Aconcagua Oct 26 '19 at 06:02
  • what does the error tell you? that `value` is not an integer type... it's an `Halide::Internal::GeneratorBase::Input`. So you cannot convert it to int. Do what @Aconcagua says – JHBonarius Oct 26 '19 at 08:56
  • Thanks to Aconcagua and JHBonarius. I am investigating tutorials. – walter Nov 07 '19 at 02:17

0 Answers0