comp-imaging / ProxImaL

A domain-specific language for image optimization.
MIT License
114 stars 29 forks source link

Using Halide implementation leads to 'undefined types' error #37

Closed multigrid101 closed 1 year ago

multigrid101 commented 7 years ago

I tried to use the Halide implementation of proximal by setting implem=Impl['halide'] in the Problem class, but I got a lot of errors if I try to use the ADMM algorithm. With the Pock-Chambolle algorithm, everything seems to work fine.

Any ideas what might be the cause of this? The first lines of the log seems to suggest that proximal is using halide types that do not exist but I somehow doubt that that is the problem^^

Btw, halide on its own is working fine for me, but running grep -r FuncRefVar in the halide root directory does not yield any results.

I also tried changing the include-statements in funct.h to point directly to Halide.h (in case there was a search-path related problem, but that did not change the error output)

Estimated params [sigma = 1.000 | tau = 1.000 | theta = 1.000 | L_est = 1.0000]
0.0818989276886
In file included from /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/complex.h:6:0,
                 from /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/fft.h:14,
                 from /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft2_r2c.cpp:11:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:11:5: error: ‘FuncRefVar’ in namespace ‘Halide’ does not name a type
     Halide::FuncRefVar untyped;
     ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:17:23: error: ‘FuncRefVar’ in namespace ‘Halide’ does not name a type
     FuncRefVarT(const Halide::FuncRefVar& untyped)
                       ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:17:43: error: ISO C++ forbids declaration of ‘untyped’ with no type [-fpermissive]
     FuncRefVarT(const Halide::FuncRefVar& untyped)
                                           ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In constructor ‘FuncRefVarT<T>::FuncRefVarT(const int&)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:18:21: error: request for member ‘function’ in ‘untyped’, which is of non-class type ‘const int’
         : T(untyped.function().has_pure_definition() ? T(Tuple(untyped)) : T()),
                     ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:19:13: error: class ‘FuncRefVarT<T>’ does not have any field named ‘untyped’
             untyped(untyped) {}
             ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefVarT<T>::Stage FuncRefVarT<T>::operator=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:21:35: error: ‘untyped’ was not declared in this scope
     Stage operator=(T x) { return untyped = x; }
                                   ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefVarT<T>::Stage FuncRefVarT<T>::operator+=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:22:36: error: ‘untyped’ was not declared in this scope
     Stage operator+=(T x) { return untyped = T(Tuple(untyped)) + x; }
                                    ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefVarT<T>::Stage FuncRefVarT<T>::operator-=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:23:36: error: ‘untyped’ was not declared in this scope
     Stage operator-=(T x) { return untyped = T(Tuple(untyped)) - x; }
                                    ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefVarT<T>::Stage FuncRefVarT<T>::operator*=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:24:36: error: ‘untyped’ was not declared in this scope
     Stage operator*=(T x) { return untyped = T(Tuple(untyped)) * x; }
                                    ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefVarT<T>::Stage FuncRefVarT<T>::operator/=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:25:36: error: ‘untyped’ was not declared in this scope
     Stage operator/=(T x) { return untyped = T(Tuple(untyped)) / x; }
                                    ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: At global scope:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:30:5: error: ‘FuncRefExpr’ in namespace ‘Halide’ does not name a type
     Halide::FuncRefExpr untyped;
     ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:36:24: error: ‘FuncRefExpr’ in namespace ‘Halide’ does not name a type
     FuncRefExprT(const Halide::FuncRefExpr& untyped)
                        ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:36:45: error: ISO C++ forbids declaration of ‘untyped’ with no type [-fpermissive]
     FuncRefExprT(const Halide::FuncRefExpr& untyped)
                                             ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In constructor ‘FuncRefExprT<T>::FuncRefExprT(const int&)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:37:30: error: class ‘FuncRefExprT<T>’ does not have any field named ‘untyped’
         : T(Tuple(untyped)), untyped(untyped) {}
                              ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefExprT<T>::Stage FuncRefExprT<T>::operator=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:39:35: error: ‘untyped’ was not declared in this scope
     Stage operator=(T x) { return untyped = x; }
                                   ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefExprT<T>::Stage FuncRefExprT<T>::operator+=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:40:36: error: ‘untyped’ was not declared in this scope
     Stage operator+=(T x) { return untyped = T(Tuple(untyped)) + x; }
                                    ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefExprT<T>::Stage FuncRefExprT<T>::operator-=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:41:36: error: ‘untyped’ was not declared in this scope
     Stage operator-=(T x) { return untyped = T(Tuple(untyped)) - x;}
                                    ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefExprT<T>::Stage FuncRefExprT<T>::operator*=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:42:36: error: ‘untyped’ was not declared in this scope
     Stage operator*=(T x) { return untyped = T(Tuple(untyped)) * x; }
                                    ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In member function ‘FuncRefExprT<T>::Stage FuncRefExprT<T>::operator/=(T)’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:43:36: error: ‘untyped’ was not declared in this scope
     Stage operator/=(T x) { return untyped = T(Tuple(untyped)) / x; }
                                    ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft2_r2c.cpp: In member function ‘Halide::NamesInterface::Func fft2_r2c_gen::build()’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft2_r2c.cpp:52:71: error: ‘WTARGET’ was not declared in this scope
         paddedInput = repeat_image( constant_exterior(input, 0.f), 0, WTARGET, 0, HTARGET);
                                                                       ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft2_r2c.cpp:52:83: error: ‘HTARGET’ was not declared in this scope
         paddedInput = repeat_image( constant_exterior(input, 0.f), 0, WTARGET, 0, HTARGET);
                                                                                   ^
In file included from /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/complex.h:6:0,
                 from /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/fft.h:14,
                 from /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft2_r2c.cpp:11:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In instantiation of ‘FuncRefExprT<T> FuncT<T>::operator()(std::vector<Halide::Expr>) const [with T = ComplexExpr]’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/fft.h:150:53:   required from here
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:74:92: error: could not convert ‘Halide::Func::operator()(std::vector<Halide::Expr>) const(std::vector<Halide::Expr>((*(const std::vector<Halide::Expr>*)(& vars))))’ from ‘Halide::FuncRef’ to ‘FuncRefExprT<ComplexExpr>’
     FuncRefExprT<T> operator()(std::vector<Expr> vars) const { return Func::operator()(vars); }
                                                                                            ^
In file included from /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/complex.h:6:0,
                 from /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/fft.h:14,
                 from /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft2_r2c.cpp:11:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In instantiation of ‘FuncRefVarT<T> FuncT<T>::operator()(std::vector<Halide::Var>) const [with T = ComplexExpr]’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/fft.h:169:15:   required from here
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:66:90: error: could not convert ‘Halide::Func::operator()(std::vector<Halide::Var>) const(std::vector<Halide::Var>((*(const std::vector<Halide::Var>*)(& vars))))’ from ‘Halide::FuncRef’ to ‘FuncRefVarT<ComplexExpr>’
     FuncRefVarT<T> operator()(std::vector<Var> vars) const { return Func::operator()(vars); }
                                                                                          ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In instantiation of ‘FuncRefVarT<T> FuncT<T>::operator()(FuncT<T>::Var) const [with T = ComplexExpr; FuncT<T>::Var = Halide::Var]’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/fft.h:301:12:   required from here
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:60:71: error: could not convert ‘Halide::Func::operator()(Args&& ...) const [with Args = {Halide::Var&}; typename std::enable_if<Halide::Internal::all_are_convertible<Halide::Var, Args ...>::value, Halide::FuncRef>::type = Halide::FuncRef]((* & x))’ from ‘std::enable_if<true, Halide::FuncRef>::type {aka Halide::FuncRef}’ to ‘FuncRefVarT<ComplexExpr>’
     FuncRefVarT<T> operator()(Var x) const { return Func::operator()(x); }
                                                                       ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In instantiation of ‘FuncRefExprT<T> FuncT<T>::operator()(FuncT<T>::Expr) const [with T = ComplexExpr; FuncT<T>::Expr = Halide::Expr]’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/fft.h:353:79:   required from here
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:68:73: error: could not convert ‘Halide::Func::operator()(Halide::Expr, Args&& ...) const [with Args = {}; typename std::enable_if<Halide::Internal::all_are_convertible<Halide::Expr, Args ...>::value, Halide::FuncRef>::type = Halide::FuncRef](Halide::Expr((*(const Halide::Expr*)(& x))))’ from ‘std::enable_if<true, Halide::FuncRef>::type {aka Halide::FuncRef}’ to ‘FuncRefExprT<ComplexExpr>’
     FuncRefExprT<T> operator()(Expr x) const { return Func::operator()(x); }
                                                                         ^
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h: In instantiation of ‘FuncRefVarT<T> FuncT<T>::operator()(FuncT<T>::Var, FuncT<T>::Var, FuncT<T>::Var) const [with T = ComplexExpr; FuncT<T>::Var = Halide::Var]’:
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft2_r2c.cpp:32:50:   required from here
/home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/src/fft/funct.h:62:91: error: could not convert ‘Halide::Func::operator()(Args&& ...) const [with Args = {Halide::Var&, Halide::Var&, Halide::Var&}; typename std::enable_if<Halide::Internal::all_are_convertible<Halide::Var, Args ...>::value, Halide::FuncRef>::type = Halide::FuncRef]((* & x), (* & y), (* & z))’ from ‘std::enable_if<true, Halide::FuncRef>::type {aka Halide::FuncRef}’ to ‘FuncRefVarT<ComplexExpr>’
     FuncRefVarT<T> operator()(Var x, Var y, Var z) const { return Func::operator()(x, y, z); }
                                                                                           ^
/bin/sh: 1: /home/sebastian/anaconda2/lib/python2.7/site-packages/proximal/halide/build/gengen.XXXX: not found
Error genererator compilation: 
ziwenjiang commented 5 years ago

Hello, I am recently starting to use Proximal. Just curious how do you set the environment to use halide? When I tried to run my code with implementation set to halide, it always returns the following error: /bin/sh: /Library/Python/2.7/site-packages/proximal-0.1.6-py2.7.egg/proximal/halide/build/gengen.XXXX: No such file or directory Can you tell me if you figure out a way to solve it? Thanks!

ziwenjiang commented 5 years ago

@multigrid101