-
Notifications
You must be signed in to change notification settings - Fork 31
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
Problem with generated resolvers (1/2) #24
Comments
@alrevuelta will look into it. |
Generate all MNIST operators with the Python script and start integrating them in the existing code. So far only float type is supported. -Python generated code is now being used -MNIST and tinyYOLO models are working -Opset and function resolver is not hardcoded anymore. TODOs for next patches (see #24 #25) -Remove unused code -Remove all switch cases in the operator (no longer needed) -There is a minor issue when resolving the operator functions. When a function is not defined (i.e. for double) there is an error because that symbol can't be found. This should be linked with the default operator stub (using weakrefs?) -There is a workaround with the operator set. opset=12 is hardcoded for the initial tests. -Modify manually maxpool resolver. The Python generator for resolvers has to be rethought. Doesn't make sense for some operators. This modification is a temporal fix until we figure out how to handle this.
I tried the mechanism with a minimal example and it works: main.c #include <stdio.h>
extern __attribute__((weak)) char* func(void);
int main() {
printf("func @ %p\n",func);
if (func) {
printf("func: %s\n", func());
} else {
printf("func not defined\n");
}
return 0;
} func.c char* func(void) {
return "hello";
}
the |
ah sorry, I misunderstood the problem |
the address operators inside the return statements are wrong. the resolver should return the function pointer itself, not the address of the function pointer. will update the generator. |
@nopeslide
After a quick search I found this where one of the solutions suggests to add the following flags |
these flags are not present in my |
Looks like its mac specific. Seems also that its not really a good idea. "Weak linking with weak_import really only works well with dynamic libraries. You can get it to work with static linking (by specifying -undefined dynamic_lookup as suggested above) but this isn't such a hot idea. It means that no undefined symbols will be detected until runtime. This is something I would avoid in production code, personally." Will look further into this. |
since we are building a static binary no symbol search should be done at runtime. could you pass the |
are you developing on a mac? if not we could keep these flags and just trust the linux gcc to report any linker errors |
If you mean something like:
I'm geetting:
And according to
Yep, I'm developing on mac. |
I looked at a few other projects with Mac ports (i.e. gcc). it seems they're all using these flags. |
You mean these flags? |
yes |
Solved in #34 |
There is a problem with the autogenerated resolvers (the ones that map a given operator with the function, i.e. argmax with argmax__float)
Lets use
resolve_operator__onnx__argmax__12
as an example. This function returns a given function depending on the type that is used (i.e.operator__onnx__argmax__12__T_tensor_float
). The problem here is that if one the functions is not implemented, the compiler can't of course find the symbol and it gives an error.This was introduced in #22 and fixed by commenting the types that are not implemented, but should be fixed, since in most of the cases we won't implement all types (float, int,...) for a given operator.
Can this be solved with weakrefs? So if the symbol is not found it automatically fallbacks to an empty operator stub?
@nopeslide
The text was updated successfully, but these errors were encountered: