-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix executor for different compilers #8006
Conversation
At the moment compiling this file throws multiple errors with C++ compilers, this change proposes to fix them. 1. `tvm_model_t->run_func` of type `TVMBackedPackedFunc` returns an int at the moment which is different from the signature of this function `tvm_runtime_run`, implicit casting is not favorable in many compile chains and throws errors. 2. The index of iterators were of type `int` while that of `model->num_input_tensors` and `model->num_output_tensors` were of type `uint32_t`, this type difference again throws errors in many toolchains, and can potentially cause incorrect calculations. 3. C Style struct initialization of tensors with `(DLTensor){...}` is not supported in many C++ toolchains and throws “non-trivial designated initializers not supported” error. Explicitly setting values should work in all cases even though it looks a little less nice.
Looks like this is a |
Yes, it is probably designed to be compiled with a C compiler, but problems 1 and 2 should be encountered with any compilation process that prohibits implicit typecasting. Additionally the file can readily be used with C++ compiler, so it might be worth changing the structure initialisation to work with C++ compilers. |
Yeah, I agree. Besides, we should better use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure this code can work well in gcc and your own compiler after these modifications.
The other parts looks good to me.
@jcf94 Changed the type and tested with gcc as well as g++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! @rijulg
* Fix executor for different compilers At the moment compiling this file throws multiple errors with C++ compilers, this change proposes to fix them. 1. `tvm_model_t->run_func` of type `TVMBackedPackedFunc` returns an int at the moment which is different from the signature of this function `tvm_runtime_run`, implicit casting is not favorable in many compile chains and throws errors. 2. The index of iterators were of type `int` while that of `model->num_input_tensors` and `model->num_output_tensors` were of type `uint32_t`, this type difference again throws errors in many toolchains, and can potentially cause incorrect calculations. 3. C Style struct initialization of tensors with `(DLTensor){...}` is not supported in many C++ toolchains and throws “non-trivial designated initializers not supported” error. Explicitly setting values should work in all cases even though it looks a little less nice. * changing type to size_t * fix format for clang
* Fix executor for different compilers At the moment compiling this file throws multiple errors with C++ compilers, this change proposes to fix them. 1. `tvm_model_t->run_func` of type `TVMBackedPackedFunc` returns an int at the moment which is different from the signature of this function `tvm_runtime_run`, implicit casting is not favorable in many compile chains and throws errors. 2. The index of iterators were of type `int` while that of `model->num_input_tensors` and `model->num_output_tensors` were of type `uint32_t`, this type difference again throws errors in many toolchains, and can potentially cause incorrect calculations. 3. C Style struct initialization of tensors with `(DLTensor){...}` is not supported in many C++ toolchains and throws “non-trivial designated initializers not supported” error. Explicitly setting values should work in all cases even though it looks a little less nice. * changing type to size_t * fix format for clang
* Fix executor for different compilers At the moment compiling this file throws multiple errors with C++ compilers, this change proposes to fix them. 1. `tvm_model_t->run_func` of type `TVMBackedPackedFunc` returns an int at the moment which is different from the signature of this function `tvm_runtime_run`, implicit casting is not favorable in many compile chains and throws errors. 2. The index of iterators were of type `int` while that of `model->num_input_tensors` and `model->num_output_tensors` were of type `uint32_t`, this type difference again throws errors in many toolchains, and can potentially cause incorrect calculations. 3. C Style struct initialization of tensors with `(DLTensor){...}` is not supported in many C++ toolchains and throws “non-trivial designated initializers not supported” error. Explicitly setting values should work in all cases even though it looks a little less nice. * changing type to size_t * fix format for clang
At the moment compiling this file throws multiple errors with C++ compilers, this change proposes to fix them.
tvm_model_t->run_func
of typeTVMBackedPackedFunc
returns an int at the moment which is different from the signature of this functiontvm_runtime_run
, implicit casting is not favorable in many compile chains and throws errors.int
while that ofmodel->num_input_tensors
andmodel->num_output_tensors
were of typeuint32_t
, this type difference again throws errors in many toolchains, and can potentially cause incorrect calculations.(DLTensor){...}
is not supported in many C++ toolchains and throws “non-trivial designated initializers not supported” error. Explicitly setting values should work in all cases even though it looks a little less nice.