Closed thibnoel closed 4 years ago
Thank you so much for filing the issue. We will look at it and take appropriate action as soon as possible.' first issue
Thanks @thibnoel for the report.
As a workaround, you can try it on platform https://cainvas.ai-tech.systems/ that hosts deepC.
Hello @srohit0, thanks for your quick answer! Your suggestion of converting the model on your platform directly worked for the step 1 of the example. However, I feel like there is something I still dont get with the overall workflow; I now tried to compile it with the example command you provide and it fails with the following errors (some of the seem due to bad naming but the others are related to dnnc I think) :
jupyter-tnoel@ip-172-31-18-137:~/deepC/test/compiler/mnist$ /usr/bin/clang++-8 -O3 testnet.cpp -I ../../../include/ -isystem ../../../packages/eigen-eigen-323c052e1731/ -o testnet.exe
In file included from testnet.cpp:24:
/home/jupyter-tnoel/testnet.h:22:7: error: expected unqualified-id
float 12[] = {
^
/home/jupyter-tnoel/testnet.h:29:7: error: expected unqualified-id
float 13[] = {
^
testnet.cpp:49:17: error: no matching constructor for initialization of 'tensor<float>'
tensor<float> dnnc_12(12, {4, 8}, "12", false);
^ ~~~~~~~~~~~~~~~~~~~~~~~
../../../include/core/tensor.h:113:3: note: candidate constructor not viable: no known conversion from 'int' to 'std::vector<DIMENSION>' (aka 'vector<unsigned long>') for 1st argument
tensor(std::vector<DIMENSION> dimn = std::vector<DIMENSION>(),
^
../../../include/core/tensor.h:123:3: note: candidate constructor not viable: requires at most 3 arguments, but 4 were provided
tensor(T *data, std::vector<DIMENSION> dimn, std::string n = "")
^
../../../include/core/tensor.h:139:3: note: candidate constructor not viable: requires single argument 'other', but 4 arguments were provided
tensor(tensor const &other) : placeHolder<T>(other) {
^
testnet.cpp:50:17: error: no matching constructor for initialization of 'tensor<float>'
tensor<float> dnnc_13(13, {8, 1}, "13", false);
^ ~~~~~~~~~~~~~~~~~~~~~~~
../../../include/core/tensor.h:113:3: note: candidate constructor not viable: no known conversion from 'int' to 'std::vector<DIMENSION>' (aka 'vector<unsigned long>') for 1st argument
tensor(std::vector<DIMENSION> dimn = std::vector<DIMENSION>(),
^
../../../include/core/tensor.h:123:3: note: candidate constructor not viable: requires at most 3 arguments, but 4 were provided
tensor(T *data, std::vector<DIMENSION> dimn, std::string n = "")
^
../../../include/core/tensor.h:139:3: note: candidate constructor not viable: requires single argument 'other', but 4 arguments were provided
tensor(tensor const &other) : placeHolder<T>(other) {
^
testnet.cpp:51:17: error: no matching constructor for initialization of 'tensor<float>'
tensor<float> dnnc_layers_dot_0_dot_bias(layers_dot_0_dot_bias, {8}, "layers_dot_0_dot_bias", false);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../include/core/tensor.h:113:3: note: candidate constructor not viable: no known conversion from 'float [8]' to 'std::vector<DIMENSION>' (aka 'vector<unsigned long>') for 1st argument
tensor(std::vector<DIMENSION> dimn = std::vector<DIMENSION>(),
^
../../../include/core/tensor.h:123:3: note: candidate constructor not viable: requires at most 3 arguments, but 4 were provided
tensor(T *data, std::vector<DIMENSION> dimn, std::string n = "")
^
../../../include/core/tensor.h:139:3: note: candidate constructor not viable: requires single argument 'other', but 4 arguments were provided
tensor(tensor const &other) : placeHolder<T>(other) {
^
testnet.cpp:52:17: error: no matching constructor for initialization of 'tensor<float>'
tensor<float> dnnc_layers_dot_1_dot_bias(layers_dot_1_dot_bias, {1}, "layers_dot_1_dot_bias", false);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../include/core/tensor.h:113:3: note: candidate constructor not viable: no known conversion from 'float [1]' to 'std::vector<DIMENSION>' (aka 'vector<unsigned long>') for 1st argument
tensor(std::vector<DIMENSION> dimn = std::vector<DIMENSION>(),
^
../../../include/core/tensor.h:123:3: note: candidate constructor not viable: requires at most 3 arguments, but 4 were provided
tensor(T *data, std::vector<DIMENSION> dimn, std::string n = "")
^
../../../include/core/tensor.h:139:3: note: candidate constructor not viable: requires single argument 'other', but 4 arguments were provided
tensor(tensor const &other) : placeHolder<T>(other) {
^
testnet.cpp:54:9: error: too many template arguments for class template 'MatMul'
dnnc::MatMul<float, float, float> MatMul_0("MatMul_0");
^ ~~~~~~~~~~~~~
../../../include/operators/MatMul.h:30:29: note: template is declared here
template <typename T> class MatMul : public baseOperator<T, T, T> {
~~~~~~~~~~~~~~~~~~~~~ ^
testnet.cpp:58:9: error: too many template arguments for class template 'Add'
dnnc::Add<float, float, float> Add_1("Add_1");
^ ~~~~~~
../../../include/operators/Add.h:37:7: note: template is declared here
class Add : public baseOperator<To, Ti, Ti> {
^
testnet.cpp:62:9: error: too many template arguments for class template 'Tanh'
dnnc::Tanh<float, float> Tanh_2("Tanh_2");
^ ~~~~~~
../../../include/operators/Tanh.h:31:29: note: template is declared here
template <typename T> class Tanh : public baseOperator<T, T, T> {
~~~~~~~~~~~~~~~~~~~~~ ^
testnet.cpp:66:9: error: too many template arguments for class template 'MatMul'
dnnc::MatMul<float, float, float> MatMul_3("MatMul_3");
^ ~~~~~~~~~~~~~
../../../include/operators/MatMul.h:30:29: note: template is declared here
template <typename T> class MatMul : public baseOperator<T, T, T> {
~~~~~~~~~~~~~~~~~~~~~ ^
testnet.cpp:70:9: error: too many template arguments for class template 'Add'
dnnc::Add<float, float, float> Add_4("Add_4");
^ ~~~~~~
../../../include/operators/Add.h:37:7: note: template is declared here
class Add : public baseOperator<To, Ti, Ti> {
^
11 errors generated.
Would you please have any leads about how to keep going? Thanks in advance! Best
@thibnoel - once the graph has errors, everything from that point is malformed. No point looking at the code, much less compiling it.
Hello @srohit0, thanks for the help, I think my graph is now correct but I will take a pause on this as I found a workaround that does not require generating the model through deepC. Anyway I might come back to it, I'm closing this issue in the meantime :) Best
Hello, I am currently trying to generate some C code from a trained PyTorch model. I tried to follow the first example provided in the tutorials ("Intermediate codegen and generate binary/bundle for your model") but the process fails at the first step. Here is how I proceed :
graph(%input.1 : Float(4), %layers.0.bias : Float(8), %layers.1.bias : Float(1), %12 : Float(4, 8), %13 : Float(8, 1)): %6 : Float(8) = onnx::MatMul(%input.1, %12) # /home/tnoel/.local/lib/python3.6/site-packages/torch/nn/functional.py:1612:0 %7 : Float(8) = onnx::Add(%6, %layers.0.bias) %8 : Float(8) = onnx::Tanh(%7) # solo_shoulder_approx_torch_nn.py:49:0 %10 : Float(1) = onnx::MatMul(%8, %13) # /home/tnoel/.local/lib/python3.6/site-packages/torch/nn/functional.py:1612:0 %11 : Float(1) = onnx::Add(%10, %layers.1.bias) return (%11)
The command still creates and populates the following files :
12
,13
,layers.0.bias
,layers.1.bias
(with numerical values), and also creates the followingtestnet.cpp
file (which looks quite not correct) :Would you please have any idea about how I should modify my model so that it is correctly handled by
onnx-cpp
? I dont really know where to look for now, and I dont see why the nodes are not correctly parsed from the ONNX model. Thanks in advance!