Error while running the example
lilingnan opened this issue · comments
Hi,I like the function of cppflow very much, but I encountered an error when I tried to run an example after installing, and it didn't work even after updating the gcc version to 9.4.0.Do you know what is the reason?
error was:
main.cpp: In function ‘int main()’:
main.cpp:45:30: error: could not convert ‘input’ from ‘cppflow::tensor’ to ‘std::__cxx11::string {aka std::__cxx11::basic_string}’
auto output = model(input);
^
main.cpp:49:35: error: expected primary-expression before ‘float’
auto values = output.get_data();
^~~~~
main.cpp:51:19: error: unable to deduce ‘auto&&’ from ‘values’
for (auto v : values) {
thanks,
li
Hi!
Can you provide a complete example of what you are trying to do? With just two lines of code is difficult to tell.
On thing that I see is that you are not telling your datatype when using get_data
, it should be something like output.get_data<float>()
.
Hi! thank you for replying me! I just tried the simple example that you offered to us:
#include <cppflow/ops.h>
#include <cppflow/model.h>
// C++ headers
#include
int main() {
auto input = cppflow::fill({10, 5}, 1.0f);
cppflow::model model(std::string(MODEL_PATH));
auto output = model(input);
std::cout << output << std::endl;
auto values = output.get_data<float>();
for (auto v : values) {
std::cout << v << std::endl;
}
return 0;
}
and "auto" reports an error as "explicit type is missing("int" assumed)
thanks,
li
Is that the only code you are using?
Could you post the complete error you getting?
Yes, only this one
main.cpp: In function ‘int main()’:
main.cpp:45:25: error: could not convert ‘input’ from ‘cppflow::tensor’ to ‘std::string’ {aka ‘std::__cxx11::basic_string’}
45 | auto output = model(input);
| ^~~~~
| |
| cppflow::tensor
main.cpp:49:35: error: expected primary-expression before ‘float’
49 | auto values = output.get_data();
| ^~~~~
It looks like the compiler is not finding the MODEL_PATH
var. Check if it's declared in the CMakeLists.txt, or change the path directly in the code:
cppflow::model model(std::string("/path/to/model"));
Thank you so much for replying me patiently, the problem has been successfully solved! thanks and happy new year!
You're welcome!