Windows 10 x64
VirtualBox 6.1
Kivy Complete VM 0.7
I'm trying to generate a simple apk file and it always returns errors, I've tried to delete the virtual machine and create it again, thinking it was the result of some configuration done previously by me. I'm new to programming, I don't find that same mistake on the internet and I don't know how to solve it.
The code in "/home/kivy/Desktop/teste/main.py":
from kivy.app import App
from kivy.uix.button import Button
class MyApp(App):
def build(self):
return Button(text='Hello World')
MyApp().run()
The commands in "/home/kivy/Desktop/teste":
buildozer init
buildozer -v android debug
Some things that return:
[INFO]: Trying first build of pyjnius to get cython files: this is expected to fail
[INFO]: -> running python3 setup.py build_ext -v
Exception in thread background thread for pid 3232:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py build_ext -v
STDOUT:
warning: [options] bootstrap class path not set in conjunction with -source 7
1 warning
running build_ext
building 'jnius' extension
creating build
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/jnius
/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include -DANDROID -D__ANDROID_API__=21 -I/home/kivy/.buildozer/android/platform/android-ndk-r19b/sysroot/usr/include/arm-linux-androideabi -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/include/python3.8 -fPIC -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Include -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build -c jnius/jnius.c -o build/temp.linux-x86_64-3.8/jnius/jnius.o
clang: error: no such file or directory: 'jnius/jnius.c'
clang: error: no input files
error: command '/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang' failed with exit status 1
STDERR:
[INFO]: pyjnius first build failed (as expected)
[INFO]: Running cython where appropriate
[INFO]: Cythonize jnius/jnius.pyx
[INFO]: -> running python3 -m Cython.Build.Cythonize ./jnius/jnius.pyx
[INFO]: -> running python3 setup.py build_ext -v
working: error: command '/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang' failed with exit status 1 Exception in thread background thread for pid 3263:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/kivy/.local/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py build_ext -v
STDOUT:
warning: [options] bootstrap class path not set in conjunction with -source 7
1 warning
running build_ext
building 'jnius' extension
/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -target armv7a-linux-androideabi21 -fomit-frame-pointer -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include -DANDROID -D__ANDROID_API__=21 -I/home/kivy/.buildozer/android/platform/android-ndk-r19b/sysroot/usr/include/arm-linux-androideabi -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/include/python3.8 -fPIC -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Include -I/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build -c jnius/jnius.c -o build/temp.linux-x86_64-3.8/jnius/jnius.o
jnius/jnius.c:3738:89: warning: incompatible pointer types passing 'JNIEnv **'
(aka 'const struct JNINativeInterface_ ***') to parameter of type
'void **' [-Wincompatible-pointer-types]
...(&__pyx_v_env), NULL));
^~~~~~~~~~~~~~
jnius/jnius.c:10723:19: warning: assigning to 'jchar *' (aka 'unsigned short *')
from 'const jchar *' (aka 'const unsigned short *') discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
...= (__pyx_v_j_env[0])->GetStringChars(__pyx_v_j_env, __pyx_v_j_string, NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:20421:30: warning: incompatible pointer types assigning to
'jobject' (aka 'struct _jobject *') from 'jobject *' (aka
'struct _jobject **'); dereference with * [-Wincompatible-pointer-types]
(__pyx_v_jargs[0]) = ((jobject *)__pyx_v_classLoader);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*( )
jnius/jnius.c:20430:30: warning: incompatible pointer types assigning to
'jobject' (aka 'struct _jobject *') from 'jclass *' (aka
'struct _jobject **'); dereference with * [-Wincompatible-pointer-types]
(__pyx_v_jargs[1]) = __pyx_v_interfaces;
^ ~~~~~~~~~~~~~~~~~~
*
jnius/jnius.c:35645:36: warning: assigning to 'char *' from 'const char *'
discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
(__pyx_v_invoke_methods[0]).name = ((char const *)"invoke0");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:35654:41: warning: assigning to 'char *' from 'const char *'
discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
...= ((char const *)"(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:51997:258: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(0, 0, 0, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_env_pxi, __pyx_n_s_detach, 23, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52009:261: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_func_pxi, __pyx_n_s_cast, 4, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52021:272: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_func_pxi, __pyx_n_s_find_javaclass, 17, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52033:263: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(5, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_init, 11, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52048:273: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_instancecheck, 43, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52060:263: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(4, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_new, 113, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52072:273: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_subclasscheck, 119, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52084:273: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_get_javaclass, 148, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52096:274: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_resolve_class, 152, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52108:280: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_init, 1051, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52120:280: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_export_class_pxi, __pyx_n_s_init, 1057, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52140:255: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__84, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_proxy_pxi, __pyx_n_s_init, 2, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52155:256: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__87, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_proxy_pxi, __pyx_n_s_get_2, 7, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52167:256: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__89, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_jnius_jnius_proxy_pxi, __pyx_n_s_call, 10, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:52232:259: error: too many arguments to function call, expected
15, have 16
...__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__96, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes)...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:57497:9: error: too many arguments to function call, expected 15,
have 16
__pyx_empty_bytes /*PyObject *lnotab*/
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
6 warnings and 16 errors generated.
error: command '/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang' failed with exit status 1
STDERR:
[INFO]: STDOUT (last 20 lines of 213):
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
jnius/jnius.c:57497:9: error: too many arguments to function call, expected 15,
have 16
__pyx_empty_bytes /*PyObject *lnotab*/
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jnius/jnius.c:331:82: note: expanded from macro '__Pyx_PyCode_New'
...PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
~~~~~~~~~~ ^~~~
/home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3/armeabi-v7a__ndk_target_21/python3/Include/code.h:122:12: note:
'PyCode_New' declared here
PyAPI_FUNC(PyCodeObject *) PyCode_New(
^
6 warnings and 16 errors generated.
error: command '/home/kivy/.buildozer/android/platform/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang' failed with exit status 1
[INFO]: STDERR:
[INFO]: COMMAND:
cd /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/pyjnius-python3-sdl2/armeabi-v7a__ndk_target_21/pyjnius && /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py build_ext -v
[WARNING]: ERROR: /home/kivy/Desktop/teste/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 failed!
Thanks in advance.
EDIT: Problem solved with another VM
Had the same issue on my Ubuntu 16.04 machine. Settings:
Virtual Environment with python=3.6.3
Kivy=1.11.1
Setup buildozer from master (b566125f71edc82b53ac0249ca710ff8fd4fea54)
Installed compatible Cython=0.29.9 as mentioned here
Solved the problem by updating to the latest Cython version (0.29.16 for me):
pip install --upgrade Cython
It seems like you don't have cython or something is wrong with cython. Consider installing it with the command mentioned from alexmazurik
Related
The C source code is as following.
#include "fdlibm.h"
#include <errno.h>
#ifdef __STDC__
double ldexp(double value, int exp)
#else
double ldexp(value, exp)
double value; int exp;
#endif
{
if(!finite(value)||value==0.0) return value;
value = scalbn(value,exp);
if(!finite(value)||value==0.0) errno = ERANGE;
return value;
}
The compilation command is "clang -emit-llvm -g -O3 -D_IEEE_LIBM -Wall -Wuninitialized -c s_ldexp.c -o s_ldexp.bc"
I transform the bitcode into human-readable LLVM assembly language using this command "llvm-dis s_ldexp.bc -o s_ldexp.ll"
The IR compiled by clang8 is as following.
; ModuleID = 's_ldexp.llvm8.O3.bc'
source_filename = "s_ldexp.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define dso_local double #ldexp(double, i32) local_unnamed_addr #0 !dbg !7 {
call void #llvm.dbg.value(metadata double %0, metadata !13, metadata !DIExpression()), !dbg !15
call void #llvm.dbg.value(metadata i32 %1, metadata !14, metadata !DIExpression()), !dbg !16
%3 = tail call double #llvm.fabs.f64(double %0) #4, !dbg !17
%4 = fcmp ueq double %3, 0x7FF0000000000000, !dbg !17
%5 = fcmp oeq double %0, 0.000000e+00, !dbg !19
%6 = or i1 %5, %4, !dbg !20
br i1 %6, label %15, label %7, !dbg !20
; <label>:7: ; preds = %2
%8 = tail call double #scalbn(double %0, i32 %1) #5, !dbg !21
call void #llvm.dbg.value(metadata double %8, metadata !13, metadata !DIExpression()), !dbg !15
%9 = tail call double #llvm.fabs.f64(double %8) #4, !dbg !22
%10 = fcmp ueq double %9, 0x7FF0000000000000, !dbg !22
%11 = fcmp oeq double %8, 0.000000e+00, !dbg !24
%12 = or i1 %11, %10, !dbg !25
br i1 %12, label %13, label %15, !dbg !25
; <label>:13: ; preds = %7
%14 = tail call i32* #__errno_location() #6, !dbg !26
store i32 34, i32* %14, align 4, !dbg !27, !tbaa !28
br label %15, !dbg !26
; <label>:15: ; preds = %13, %7, %2
%16 = phi double [ %0, %2 ], [ %8, %7 ], [ %8, %13 ], !dbg !32
ret double %16, !dbg !33
}
; Function Attrs: nounwind readnone speculatable
declare double #llvm.fabs.f64(double) #1
; Function Attrs: nounwind
declare dso_local double #scalbn(double, i32) local_unnamed_addr #2
; Function Attrs: nounwind readnone
declare dso_local i32* #__errno_location() local_unnamed_addr #3
; Function Attrs: nounwind readnone speculatable
declare void #llvm.dbg.value(metadata, metadata, metadata) #1
attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone speculatable }
attributes #2 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { readnone }
attributes #5 = { nounwind }
attributes #6 = { nounwind readnone }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0 (tags/RELEASE_800/final)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
!1 = !DIFile(filename: "s_ldexp.c", directory: "/root/test/ficl/fdlibm53")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 8.0.0 (tags/RELEASE_800/final)"}
!7 = distinct !DISubprogram(name: "ldexp", scope: !1, file: !1, line: 18, type: !8, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10, !11}
!10 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !{!13, !14}
!13 = !DILocalVariable(name: "value", arg: 1, scope: !7, file: !1, line: 18, type: !10)
!14 = !DILocalVariable(name: "exp", arg: 2, scope: !7, file: !1, line: 18, type: !11)
!15 = !DILocation(line: 18, column: 22, scope: !7)
!16 = !DILocation(line: 18, column: 33, scope: !7)
!17 = !DILocation(line: 24, column: 6, scope: !18)
!18 = distinct !DILexicalBlock(scope: !7, file: !1, line: 24, column: 5)
!19 = !DILocation(line: 24, column: 26, scope: !18)
!20 = !DILocation(line: 24, column: 19, scope: !18)
!21 = !DILocation(line: 25, column: 10, scope: !7)
!22 = !DILocation(line: 26, column: 6, scope: !23)
!23 = distinct !DILexicalBlock(scope: !7, file: !1, line: 26, column: 5)
!24 = !DILocation(line: 26, column: 26, scope: !23)
!25 = !DILocation(line: 26, column: 19, scope: !23)
!26 = !DILocation(line: 26, column: 33, scope: !23)
!27 = !DILocation(line: 26, column: 39, scope: !23)
!28 = !{!29, !29, i64 0}
!29 = !{!"int", !30, i64 0}
!30 = !{!"omnipotent char", !31, i64 0}
!31 = !{!"Simple C/C++ TBAA"}
!32 = !DILocation(line: 0, scope: !7)
!33 = !DILocation(line: 28, column: 1, scope: !7)
The IR compiled by clang11 is as following.
; ModuleID = 's_ldexp.llvm11.O3.bc'
source_filename = "s_ldexp.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define dso_local double #ldexp(double %0, i32 %1) local_unnamed_addr #0 !dbg !7 {
call void #llvm.dbg.value(metadata double %0, metadata !13, metadata !DIExpression()), !dbg !15
call void #llvm.dbg.value(metadata i32 %1, metadata !14, metadata !DIExpression()), !dbg !15
%3 = tail call double #llvm.fabs.f64(double %0) #4, !dbg !16
%4 = fcmp ueq double %3, 0x7FF0000000000000, !dbg !16
%5 = fcmp oeq double %0, 0.000000e+00
%6 = or i1 %5, %4, !dbg !18
br i1 %6, label %15, label %7, !dbg !18
7: ; preds = %2
%8 = tail call double #scalbn(double %0, i32 %1) #5, !dbg !19
call void #llvm.dbg.value(metadata double %8, metadata !13, metadata !DIExpression()), !dbg !15
%9 = tail call double #llvm.fabs.f64(double %8) #4, !dbg !20
%10 = fcmp ueq double %9, 0x7FF0000000000000, !dbg !20
%11 = fcmp oeq double %8, 0.000000e+00
%12 = or i1 %11, %10, !dbg !22
br i1 %12, label %13, label %15, !dbg !22
13: ; preds = %7
%14 = tail call i32* #__errno_location() #6, !dbg !23
store i32 34, i32* %14, align 4, !dbg !24, !tbaa !25
br label %15, !dbg !23
15: ; preds = %13, %7, %2
%16 = phi double [ %0, %2 ], [ %8, %7 ], [ %8, %13 ], !dbg !15
ret double %16, !dbg !29
}
; Function Attrs: nounwind readnone speculatable willreturn
declare double #llvm.fabs.f64(double) #1
; Function Attrs: nounwind
declare dso_local double #scalbn(double, i32) local_unnamed_addr #2
; Function Attrs: nounwind readnone
declare dso_local i32* #__errno_location() local_unnamed_addr #3
; Function Attrs: nounwind readnone speculatable willreturn
declare void #llvm.dbg.value(metadata, metadata, metadata) #1
attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone speculatable willreturn }
attributes #2 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #4 = { readnone }
attributes #5 = { nounwind }
attributes #6 = { nounwind readnone }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 0160ad802e899c2922bc9b29564080c22eb0908c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "s_ldexp.c", directory: "/root/test/ficl/fdlibm53")
!2 = !{}
!3 = !{i32 7, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 0160ad802e899c2922bc9b29564080c22eb0908c)"}
!7 = distinct !DISubprogram(name: "ldexp", scope: !1, file: !1, line: 18, type: !8, scopeLine: 23, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10, !11}
!10 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !{!13, !14}
!13 = !DILocalVariable(name: "value", arg: 1, scope: !7, file: !1, line: 18, type: !10)
!14 = !DILocalVariable(name: "exp", arg: 2, scope: !7, file: !1, line: 18, type: !11)
!15 = !DILocation(line: 0, scope: !7)
!16 = !DILocation(line: 24, column: 6, scope: !17)
!17 = distinct !DILexicalBlock(scope: !7, file: !1, line: 24, column: 5)
!18 = !DILocation(line: 24, column: 19, scope: !17)
!19 = !DILocation(line: 25, column: 10, scope: !7)
!20 = !DILocation(line: 26, column: 6, scope: !21)
!21 = distinct !DILexicalBlock(scope: !7, file: !1, line: 26, column: 5)
!22 = !DILocation(line: 26, column: 19, scope: !21)
!23 = !DILocation(line: 26, column: 33, scope: !21)
!24 = !DILocation(line: 26, column: 39, scope: !21)
!25 = !{!26, !26, i64 0}
!26 = !{!"int", !27, i64 0}
!27 = !{!"omnipotent char", !28, i64 0}
!28 = !{!"Simple C/C++ TBAA"}
!29 = !DILocation(line: 28, column: 1, scope: !7)
In the s_ldexp.c, there one code snippet “value==0.0”.
The corresponding IR compiled by clang8 is "%5 = fcmp oeq double %0, 0.000000e+00, !dbg !19".
The corresponding IR compiled by clang11 is "%5 = fcmp oeq double %0, 0.000000e+00".
Compared with clang8, the debug info "!dbg !19" is missing in the corresponding IR compiled by clang11. The debug info is important to me. I hope that LLVM11 can reserve the debug info. For LLVM11, there are there methods that can solve the problem.
The first method is to run these two commands.
clang -emit-llvm -O3 -D_IEEE_LIBM -Wall -Wuninitialized -c s_ldexp.c -o s_ldexp.bc
opt -enable-debugify s_ldexp.bc -o s_ldexp.debug.bc
When using clang to compile source code, "-g" parameter is not used. And we can use llvm opt command to attach debug info into the IR.
The second method is to run this command.
clang -emit-llvm -g -O0 -D_IEEE_LIBM -Wall -Wuninitialized -c s_ldexp.c -o s_ldexp.bc
The command is to lower the optimization level of compiler and keep as much debug info as possible.
The third method is to modify the C source code.
The code after modification is as following.
#include "fdlibm.h"
#include <errno.h>
#include <stdbool.h>
#ifdef __STDC__
double ldexp(double value, int exp)
#else
double ldexp(value, exp)
double value; int exp;
#endif
{
bool flag1 = (!finite(value)) || (value==0.0);
if(flag1) return value;
value = scalbn(value,exp);
bool flag2 = (!finite(value)) || (value==0.0);
if(flag2) errno = ERANGE;
return value;
}
We can get around this problem using the third method.
Though these three method can solve this problem, I still have two questions.
The first question is why the debug info is missing in the IR compiled by clang11.
The second question is that is there any option or LLVM pass can check whether some debug info is missing and complement the missing debug info.
I'm trying to produce some results with post-hoc explainability method RISE link. For this I used a ResNet34 model trained on my custom dataset without pretrained weights. The input for this is (560, 560, 1), so the images are greyscale with size 560x560.
Somehow, Rise expects to have RGB images while the input image + model has the same greyscale shape.Does anyone know wheter RISE can only be used with RGB images or how to solve this problem?
It seems that in easy_start_ipybn (RISE) before getting fed into def generate_masks the images get resshaped into (560, 560, 3)
Running
sal = explain(model, x, masks)
provides this error:
ValueError Traceback (most recent call last)
<ipython-input-24-cf56f9bf1828> in <module>
----> 1 sal = explain(model, x, masks)
3 frames
/usr/local/lib/python3.8/dist-packages/keras/engine/training.py in tf__predict_function(iterator)
13 try:
14 do_return = True
---> 15 retval_ = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
16 except:
17 do_return = False
ValueError: in user code:
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1845, in predict_function *
return step_function(self, iterator)
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1834, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1823, in run_step **
outputs = model.predict_step(data)
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1791, in predict_step
return self(x, training=False)
File "/usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
ValueError: Exception encountered when calling layer "res_net_type_i" (type ResNetTypeI).
Could not find matching concrete function to call loaded from the SavedModel. Got:
Positional arguments (3 total):
* <tf.Tensor 'inputs:0' shape=(None, 560, 560, 3) dtype=float32>
* False
* None
Keyword arguments: {}
Expected these arguments to match one of the following 4 option(s):
Option 1:
Positional arguments (3 total):
* TensorSpec(shape=(None, 560, 560, 1), dtype=tf.float32, name='inputs')
* False
* None
Keyword arguments: {}
Option 2:
Positional arguments (3 total):
* TensorSpec(shape=(None, 560, 560, 1), dtype=tf.float32, name='inputs')
* True
* None
Keyword arguments: {}
Option 3:
Positional arguments (3 total):
* TensorSpec(shape=(None, 560, 560, 1), dtype=tf.float32, name='input_1')
* False
* None
Keyword arguments: {}
Option 4:
Positional arguments (3 total):
* TensorSpec(shape=(None, 560, 560, 1), dtype=tf.float32, name='input_1')
* True
* None
Keyword arguments: {}
Call arguments received by layer "res_net_type_i" (type ResNetTypeI):
• args=('tf.Tensor(shape=(None, 560, 560, 3), dtype=float32)',)
• kwargs={'training': 'False'}
I used to work with pydrake and recently I want to use drake in C++. I am not experienced with C++. I find that the symbolic expression calculation in C++ drake has some strange behaviors. For example,
in pydrake, I can have
prog = MathematicalProgram()
v = prog.NewContinuousVariables(7, 'v')
prog.AddCost((J_G.dot(v) - V_G_desired).dot(J_G.dot(v) - V_G_desired) + 0.01* v.dot(v))
which works fine. However, in C++, if I write similarly,
drake::solvers::MathematicalProgram prog;
auto v = prog.NewContinuousVariables(7, "v");
prog.AddCost((J_V_WS*v - V_WS).dot(J_V_WS*v - V_WS) + 0.01*v.dot(v));
I would get a long error message:
In file included from external/eigen/include/_usr_include_eigen3/Eigen/Core:372,
from bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/common/autodiff.h:12,
from bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/common/default_scalars.h:3,
from bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/systems/framework/leaf_system.h:14,
from ./kuka/diffIK_controller.h:3,
from kuka/diffIK_controller.cc:3:
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/GenericPacketMath.h: In instantiation of 'Packet Eigen::internal::pmul(const Packet&, const Packet&) [with Packet = drake::symbolic::Variable]':
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/util/BlasUtil.h:75:116: required from 'Scalar Eigen::internal::conj_helper<Scalar, Scalar, false, false>::pmul(const Scalar&, const Scalar&) const [with Scalar = drake::symbolic::Variable]'
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/functors/BinaryFunctors.h:120:66: required from 'const result_type Eigen::internal::scalar_conj_product_op<LhsScalar, RhsScalar>::operator()(const LhsScalar&, const RhsScalar&) const [with LhsScalar = drake::symbolic::Variable; RhsScalar = drake::symbolic::Variable; Eigen::internal::scalar_conj_product_op<LhsScalar, RhsScalar>::result_type = drake::symbolic::Expression]'
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/CoreEvaluators.h:713:74: required from 'Eigen::internal::binary_evaluator<Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>, Eigen::internal::IndexBased, Eigen::internal::IndexBased>::CoeffReturnType Eigen::internal::binary_evaluator<Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>, Eigen::internal::IndexBased, Eigen::internal::IndexBased>::coeff(Eigen::Index, Eigen::Index) const [with BinaryOp = Eigen::internal::scalar_conj_product_op<drake::symbolic::Variable, drake::symbolic::Variable>; Lhs = const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>; Rhs = const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>; typename Eigen::internal::traits<typename Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::Rhs>::Scalar = drake::symbolic::Variable; typename Eigen::internal::traits<typename Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::Lhs>::Scalar = drake::symbolic::Variable; Eigen::internal::binary_evaluator<Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>, Eigen::internal::IndexBased, Eigen::internal::IndexBased>::CoeffReturnType = const drake::symbolic::Expression; Eigen::Index = long int]'
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/Redux.h:381:84: required from 'Eigen::internal::redux_evaluator<_XprType>::CoeffReturnType Eigen::internal::redux_evaluator<_XprType>::coeffByOuterInner(Eigen::Index, Eigen::Index) const [with _XprType = Eigen::CwiseBinaryOp<Eigen::internal::scalar_conj_product_op<drake::symbolic::Variable, drake::symbolic::Variable>, const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>, const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1> >; Eigen::internal::redux_evaluator<_XprType>::CoeffReturnType = const drake::symbolic::Expression; Eigen::Index = long int]'
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/Redux.h:194:9: required from 'static Eigen::internal::redux_impl<Func, Derived, 0, 0>::Scalar Eigen::internal::redux_impl<Func, Derived, 0, 0>::run(const Derived&, const Func&) [with Func = Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>; Derived = Eigen::internal::redux_evaluator<Eigen::CwiseBinaryOp<Eigen::internal::scalar_conj_product_op<drake::symbolic::Variable, drake::symbolic::Variable>, const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>, const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1> > >; Eigen::internal::redux_impl<Func, Derived, 0, 0>::Scalar = drake::symbolic::Expression]'
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/Redux.h:418:56: required from 'typename Eigen::internal::traits<T>::Scalar Eigen::DenseBase<Derived>::redux(const Func&) const [with BinaryOp = Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>; Derived = Eigen::CwiseBinaryOp<Eigen::internal::scalar_conj_product_op<drake::symbolic::Variable, drake::symbolic::Variable>, const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>, const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1> >; typename Eigen::internal::traits<T>::Scalar = drake::symbolic::Expression]'
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/Redux.h:453:73: required from 'typename Eigen::internal::traits<T>::Scalar Eigen::DenseBase<Derived>::sum() const [with Derived = Eigen::CwiseBinaryOp<Eigen::internal::scalar_conj_product_op<drake::symbolic::Variable, drake::symbolic::Variable>, const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>, const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1> >; typename Eigen::internal::traits<T>::Scalar = drake::symbolic::Expression]'
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/Dot.h:37:52: required from 'static Eigen::internal::dot_nocheck<T, U, NeedToTranspose>::ResScalar Eigen::internal::dot_nocheck<T, U, NeedToTranspose>::run(const Eigen::MatrixBase<Derived>&, const Eigen::MatrixBase<U>&) [with T = Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>; U = Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>; bool NeedToTranspose = false; Eigen::internal::dot_nocheck<T, U, NeedToTranspose>::ResScalar = drake::symbolic::Expression]'
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/Dot.h:84:58: required from 'typename Eigen::ScalarBinaryOpTraits<typename Eigen::internal::traits<T>::Scalar, typename Eigen::internal::traits<OtherDerived>::Scalar>::ReturnType Eigen::MatrixBase<Derived>::dot(const Eigen::MatrixBase<OtherDerived>&) const [with OtherDerived = Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>; Derived = Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1>; typename Eigen::ScalarBinaryOpTraits<typename Eigen::internal::traits<T>::Scalar, typename Eigen::internal::traits<OtherDerived>::Scalar>::ReturnType = drake::symbolic::Expression]'
kuka/diffIK_controller.cc:52:67: required from 'drake::VectorX<T> DiffIKController<T>::CalcDiffIK(drake::MatrixX<double>, drake::VectorX<double>) const [with T = double; drake::VectorX<T> = Eigen::Matrix<double, -1, 1>; drake::MatrixX<double> = Eigen::Matrix<double, -1, -1>; drake::VectorX<double> = Eigen::Matrix<double, -1, 1>]'
kuka/diffIK_controller.cc:67:16: required from here
external/eigen/include/_usr_include_eigen3/Eigen/src/Core/GenericPacketMath.h:171:37: error: could not convert 'drake::symbolic::operator*(drake::symbolic::Expression, const drake::symbolic::Expression&)(drake::symbolic::Expression((* & b)))' from 'drake::symbolic::Expression' to 'drake::symbolic::Variable'
171 | const Packet& b) { return a*b; }
| ^
| |
| drake::symbolic::Expression
Target //kuka:diffIK_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 5.876s, Critical Path: 5.72s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
I find that by simply adding a paraenthesis around 0.01*v would solve this error:
prog.AddCost((J_V_WS*v - V_WS).dot(J_V_WS*v - V_WS) + (0.01*v).dot(v));
However, use the transpose method to do the inner product would still have issues:
prog.AddCost((J_V_WS*v - V_WS).transpose()*(J_V_WS*v - V_WS) + (0.01*v).transpose()*(v));
The error info is:
kuka/diffIK_controller.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 319 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox
kuka/diffIK_controller.cc: In member function 'drake::VectorX<T> DiffIKController<T>::CalcDiffIK(drake::MatrixX<double>, drake::VectorX<double>) const':
kuka/diffIK_controller.cc:53:90: error: no matching function for call to 'drake::solvers::MathematicalProgram::AddCost(const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>, const Eigen::Product<Eigen::Transpose<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> > >, Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> >, 0>, const Eigen::Matrix<drake::symbolic::Expression, 1, 1, 0, 1, 1> >)'
53 | prog.AddCost((J_V_WS*v - V_WS).transpose()*(J_V_WS*v - V_WS) + (0.01*v).transpose()*(v));
| ^
In file included from kuka/diffIK_controller.cc:5:
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:863:17: note: candidate: 'drake::solvers::Binding<drake::solvers::Cost> drake::solvers::MathematicalProgram::AddCost(const drake::solvers::Binding<drake::solvers::Cost>&)'
863 | Binding<Cost> AddCost(const Binding<Cost>& binding);
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:863:46: note: no known conversion for argument 1 from 'const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>, const Eigen::Product<Eigen::Transpose<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> > >, Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> >, 0>, const Eigen::Matrix<drake::symbolic::Expression, 1, 1, 0, 1, 1> >' to 'const drake::solvers::Binding<drake::solvers::Cost>&'
863 | Binding<Cost> AddCost(const Binding<Cost>& binding);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:873:8: note: candidate: 'template<class C> auto drake::solvers::MathematicalProgram::AddCost(const std::shared_ptr<_Tp>&, const Eigen::Ref<const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1> >&)'
873 | auto AddCost(const std::shared_ptr<C>& obj,
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:873:8: note: template argument deduction/substitution failed:
kuka/diffIK_controller.cc:53:90: note: 'const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>, const Eigen::Product<Eigen::Transpose<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> > >, Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> >, 0>, const Eigen::Matrix<drake::symbolic::Expression, 1, 1, 0, 1, 1> >' is not derived from 'const std::shared_ptr<_Tp>'
53 | prog.AddCost((J_V_WS*v - V_WS).transpose()*(J_V_WS*v - V_WS) + (0.01*v).transpose()*(v));
| ^
In file included from kuka/diffIK_controller.cc:5:
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:888:8: note: candidate: 'template<class C> auto drake::solvers::MathematicalProgram::AddCost(const std::shared_ptr<_Tp>&, const VariableRefList&)'
888 | auto AddCost(const std::shared_ptr<C>& obj, const VariableRefList& vars) {
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:888:8: note: template argument deduction/substitution failed:
kuka/diffIK_controller.cc:53:90: note: 'const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>, const Eigen::Product<Eigen::Transpose<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> > >, Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> >, 0>, const Eigen::Matrix<drake::symbolic::Expression, 1, 1, 0, 1, 1> >' is not derived from 'const std::shared_ptr<_Tp>'
53 | prog.AddCost((J_V_WS*v - V_WS).transpose()*(J_V_WS*v - V_WS) + (0.01*v).transpose()*(v));
| ^
In file included from kuka/diffIK_controller.cc:5:
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:911:3: note: candidate: 'template<class F> std::enable_if_t<drake::solvers::internal::is_cost_functor_candidate<F>::value, drake::solvers::Binding<drake::solvers::Cost> > drake::solvers::MathematicalProgram::AddCost(F&&, const VariableRefList&)'
911 | AddCost(F&& f, const VariableRefList& vars) {
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:911:3: note: template argument deduction/substitution failed:
kuka/diffIK_controller.cc:53:90: note: candidate expects 2 arguments, 1 provided
53 | prog.AddCost((J_V_WS*v - V_WS).transpose()*(J_V_WS*v - V_WS) + (0.01*v).transpose()*(v));
| ^
In file included from kuka/diffIK_controller.cc:5:
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:925:3: note: candidate: 'template<class F> std::enable_if_t<drake::solvers::internal::is_cost_functor_candidate<F>::value, drake::solvers::Binding<drake::solvers::Cost> > drake::solvers::MathematicalProgram::AddCost(F&&, const Eigen::Ref<const Eigen::Matrix<drake::symbolic::Variable, -1, 1, 0, -1, 1> >&)'
925 | AddCost(F&& f, const Eigen::Ref<const VectorXDecisionVariable>& vars) {
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:925:3: note: template argument deduction/substitution failed:
kuka/diffIK_controller.cc:53:90: note: candidate expects 2 arguments, 1 provided
53 | prog.AddCost((J_V_WS*v - V_WS).transpose()*(J_V_WS*v - V_WS) + (0.01*v).transpose()*(v));
| ^
In file included from kuka/diffIK_controller.cc:5:
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:940:3: note: candidate: 'template<class F, class Vars> std::enable_if_t<drake::solvers::internal::assert_if_is_constraint<F>::value, drake::solvers::Binding<drake::solvers::Cost> > drake::solvers::MathematicalProgram::AddCost(F&&, Vars&&)'
940 | AddCost(F&&, Vars&&) {
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:940:3: note: template argument deduction/substitution failed:
kuka/diffIK_controller.cc:53:90: note: candidate expects 2 arguments, 1 provided
53 | prog.AddCost((J_V_WS*v - V_WS).transpose()*(J_V_WS*v - V_WS) + (0.01*v).transpose()*(v));
| ^
In file included from kuka/diffIK_controller.cc:5:
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:951:23: note: candidate: 'drake::solvers::Binding<drake::solvers::LinearCost> drake::solvers::MathematicalProgram::AddCost(const drake::solvers::Binding<drake::solvers::LinearCost>&)'
951 | Binding<LinearCost> AddCost(const Binding<LinearCost>& binding);
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:951:58: note: no known conversion for argument 1 from 'const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>, const Eigen::Product<Eigen::Transpose<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> > >, Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> >, 0>, const Eigen::Matrix<drake::symbolic::Expression, 1, 1, 0, 1, 1> >' to 'const drake::solvers::Binding<drake::solvers::LinearCost>&'
951 | Binding<LinearCost> AddCost(const Binding<LinearCost>& binding);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:1001:26: note: candidate: 'drake::solvers::Binding<drake::solvers::QuadraticCost> drake::solvers::MathematicalProgram::AddCost(const drake::solvers::Binding<drake::solvers::QuadraticCost>&)'
1001 | Binding<QuadraticCost> AddCost(const Binding<QuadraticCost>& binding);
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:1001:64: note: no known conversion for argument 1 from 'const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>, const Eigen::Product<Eigen::Transpose<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> > >, Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> >, 0>, const Eigen::Matrix<drake::symbolic::Expression, 1, 1, 0, 1, 1> >' to 'const drake::solvers::Binding<drake::solvers::QuadraticCost>&'
1001 | Binding<QuadraticCost> AddCost(const Binding<QuadraticCost>& binding);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:1107:23: note: candidate: 'drake::solvers::Binding<drake::solvers::L2NormCost> drake::solvers::MathematicalProgram::AddCost(const drake::solvers::Binding<drake::solvers::L2NormCost>&)'
1107 | Binding<L2NormCost> AddCost(const Binding<L2NormCost>& binding);
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:1107:58: note: no known conversion for argument 1 from 'const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>, const Eigen::Product<Eigen::Transpose<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> > >, Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> >, 0>, const Eigen::Matrix<drake::symbolic::Expression, 1, 1, 0, 1, 1> >' to 'const drake::solvers::Binding<drake::solvers::L2NormCost>&'
1107 | Binding<L2NormCost> AddCost(const Binding<L2NormCost>& binding);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:1170:17: note: candidate: 'drake::solvers::Binding<drake::solvers::Cost> drake::solvers::MathematicalProgram::AddCost(const drake::symbolic::Expression&)'
1170 | Binding<Cost> AddCost(const symbolic::Expression& e);
| ^~~~~~~
bazel-out/k8-opt/bin/external/drake/tools/install/libdrake/_virtual_includes/drake_shared_library/drake/solvers/mathematical_program.h:1170:53: note: no known conversion for argument 1 from 'const Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<drake::symbolic::Expression, drake::symbolic::Expression>, const Eigen::Product<Eigen::Transpose<const Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> > >, Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<drake::symbolic::Expression, double>, const Eigen::Matrix<drake::symbolic::Expression, -1, 1, 0, -1, 1>, const Eigen::Matrix<double, -1, 1> >, 0>, const Eigen::Matrix<drake::symbolic::Expression, 1, 1, 0, 1, 1> >' to 'const drake::symbolic::Expression&'
1170 | Binding<Cost> AddCost(const symbolic::Expression& e);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Target //kuka:diffIK_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 5.757s, Critical Path: 5.61s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
What's more, I find that
prog.AddCost(v.dot(v))
would cause error while
prog.AddCost(v.transpose() * v);
would work fine.
Why would the symbolic calculations in C++ drake have above behaviors? Is there some guidance on how to do symbolic calculations with drake in C++? Thank you very much for your help.
We have two different class, symbolic::Variable and symbolic::Expression. We first create symbolic::Variable (for example using prog.NewContinuousVariables()), and then do some algebraic operation on these symbolic::Variable objects to get a symbolic::Expression.
In pydrake, we can convert symbolic::Variable to symbolic::Expression automatically. But in C++, the user has to explicitly do that conversion. I modified your code here
prog.AddCost((J_V_WS*v - V_WS).dot(J_V_WS*v - V_WS) + 0.01*v.cast<symbolic::Expression>().dot(v));
Note that I did v.cast<symbolic::Expression>().dot(v) to explicitly change v from a vector of symbolic::Variable to a vector of symbolic::Expression.
As you said, doing (0.01* v) also solves the problem, that is because when we have a double scalar multiply a symbolic::Variable, we end up with a symbolic::Expression.
I am trying to write a function to create a CNN model. I get the following error whenever I run the script:
lua:15: unexpected symbol near '['
require('torch')
require('nn')
function CeateNvidiaModel()
--The Nvidia model
--Input dimensions
local n_channels = 3
local height = 66
local width = 200
local nvidia_model = nn.Sequential();
--nvida_model:add(nn.Normalize()
--Convolutional Layers
nvidia_model:add(nn.SpatialConvolution(n_channels, 24, 5, 5, [2], [2]))
nvidia_model:add(nn.ELU(true))
nvidia_model:add(nn.SpatialConvolution(24, 36, 5, 5, [2], [2]))
nvidia_model:add(nn.ELU(true))
nvidia_model:add(nn.SpatialConvolution(36, 48, 5, 5, [2], [2]))
nvidia_model:add(nn.ELU(true))
nvidia_model:add(nn.SpatialConvolution(48, 64, 3, 3))
nvidia_model:add(nn.ELU(true))
nvidia_model:add(nn.SpatialConvolution(64, 64, 3, 3))
nvidia_model:add(nn.ELU(true))
-- Flatten Layer
nvidia_model:add(nn.Reshape(1164))
-- FC Layers
nvida_model:add(nn.Linear(1164, 100))
nvidia_model:add(nn.ELU(true))
nvida_model:add(nn.Linear(100, 50))
nvidia_model:add(nn.ELU(true))
nvida_model:add(nn.Linear(50, 10))
nvidia_model:add(nn.ELU(true))
nvida_model:add(nn.Linear(10, 1))
return nvida_model
end
I assume you are confusing [] and {}. In many other languages, you write array literals as [1, 2, 3], but in Lua [ and ] are only used for indexing; to declare an "array literal", you write {1, 2, 3} (because arrays in Lua are just tables).
The error message is a bit misleading; it says unexpected symbol near '[', but in reality the [ is the unexpected symbol.
Here is what I want to implement f(x) with tensorflow
input x = (x1,x2,x3,x4,x5,x6,x7,x8,x9)
define f(x) = f1(x1,x2,x3,x4,x5) + f2(x5,x6,x7,x8,x9)
where
f1(x1,x2,x3,x4,x5) = {1 if
(x1,x2,x3,x4,x5)=(0,0,0,0,0),
g1(x1,x2,x3,x4,x5) otherwise}
f2(x5,x6,x7,x8,x9) = {1 if
(x5,x6,x7,x8,x9)=(0,0,0,0,0),
g2(x5,x6,x7,x8,x9) otherwise}
This is my tensorflow code
import tensorflow as tf
import numpy as np
ph = tf.placeholder(dtype=tf.float32, shape=[None, 9])
x1 = tf.slice(ph, [0, 0], [-1, 5])
x2 = tf.slice(ph, [0, 4], [-1, 5])
fixed1 = tf.placeholder(dtype=tf.float32, shape=[1, 5])
fixed2 = tf.placeholder(dtype=tf.float32, shape=[1, 5])
# MLP 1
w1 = tf.Variable(tf.ones([5, 1]))
g1 = tf.matmul(x1, w1)
# MLP 2
w2 = tf.Variable(-tf.ones([5, 1]))
g2 = tf.matmul(x2, w2)
check1 = tf.reduce_all(tf.equal(x1, fixed1), axis=1, keep_dims=True)
check2 = tf.reduce_all(tf.equal(x2, fixed2), axis=1, keep_dims=True)
#### with Problem
f1 = tf.cond(check1,
lambda: tf.constant([2], dtype=tf.float32), lambda: g1)
f2 = tf.cond(check2,
lambda: tf.constant([1], dtype=tf.float32), lambda: g2)
####
f = tf.add(f1, f2)
x = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 0, 0, 0, 0, 0],
[9, 0, 0, 0, 0, 0, 0, 0, 0]])
fixed = np.array([[0, 0, 0, 0, 0]])
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print('(1)\n', sess.run(check1, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
print('(2)\n', sess.run(check2, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
print('(3)\n', sess.run(f, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
print('(4)\n', sess.run(f1, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
print('(5)\n', sess.run(f2, feed_dict={ph: x, fixed1: fixed, fixed2: fixed}))
In this case,
check1 is [[ True], [ True], [False], [False], [False]] with shape (5, 1)
check2 is [[ True], [False], [ True], [ True], [ True]] with shape (5, 1)
I expect result of f is [[3], [1], [2], [3], [10]]
but seems like tf.cond() can not handle input as boolean tensors with shape (5, 1)
Could you advice how to implement f(x) with tensorflow, please.
This is Error message what i received
Traceback (most recent call last): File
"C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py",
line 670, in _call_cpp_shape_fn_impl
status) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\contextlib.py",
line 66, in exit
next(self.gen) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py",
line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape
must be rank 0 but is rank 2 for 'cond/Switch' (op: 'Switch') with
input shapes: [?,1], [?,1].
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:/Users/hong/Dropbox/MLILAB/Research/GM-MLP/code/tensorflow_cond.py",
line 23, in
lambda: tf.constant([2], dtype=tf.float32), lambda: g1) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\ops\control_flow_ops.py",
line 1765, in cond
p_2, p_1 = switch(pred, pred) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\ops\control_flow_ops.py",
line 318, in switch
return gen_control_flow_ops._switch(data, pred, name=name) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_control_flow_ops.py",
line 368, in _switch
result = _op_def_lib.apply_op("Switch", data=data, pred=pred, name=name) File
"C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py",
line 759, in apply_op
op_def=op_def) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py",
line 2242, in create_op
set_shapes_for_outputs(ret) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py",
line 1617, in set_shapes_for_outputs
shapes = shape_func(op) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py",
line 1568, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py",
line 610, in call_cpp_shape_fn
debug_python_shape_fn, require_shape_fn) File "C:\Users\hong\AppData\Local\Continuum\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py",
line 675, in _call_cpp_shape_fn_impl
raise ValueError(err.message) ValueError: Shape must be rank 0 but is rank 2 for 'cond/Switch' (op: 'Switch') with input shapes: [?,1],
[?,1].
Process finished with exit code 1
I think you need tf.where, not tf.cond.
See the answer to this question: How to use tf.cond for batch processing