Missing symbols in tensorflow lite static library

665 views
Skip to first unread message

Aaron Boxer

unread,
Feb 20, 2020, 7:46:06 AM2/20/20
to SIG Build
Hello!
I am building a static library of the tf lite gl delegate, from master branch,
like so:

bazel build --cxxopt="--std=c++11" --copt="-DMESA_EGL_NO_X11_HEADERS" -c opt tensorflow/lite/delegates/gpu:gl_delegate


However, I find that there are a number of undefined symbols in the static library


For example, tflite::gpu::GlBuffer is undefined.


Any ideas on how to fix this?


Thanks so much,

Aaron

Aaron Boxer

unread,
Feb 20, 2020, 7:54:36 AM2/20/20
to SIG Build


On Thursday, February 20, 2020 at 7:46:06 AM UTC-5, Aaron Boxer wrote:
Hello!
I am building a static library of the tf lite gl delegate, from master branch,
like so:

bazel build --cxxopt="--std=c++11" --copt="-DMESA_EGL_NO_X11_HEADERS" -c opt tensorflow/lite/delegates/gpu:gl_delegate


However, I find that there are a number of undefined symbols in the static library



Here is a dump of the errors:

/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `glBindBuffer'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::GlBuffer::operator=(tflite::gpu::gl::GlBuffer&&)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::ConverterBhwcToPhwc4::Create(tflite::gpu::gl::ConverterBhwcToPhwc4*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::NewNodeShaderRegistry()'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::ObjectManager::FindBuffer(unsigned int) const'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::ConverterPhwc4ToBhwc::Create(tflite::gpu::gl::ConverterPhwc4ToBhwc*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `glGenBuffers'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::Compile(tflite::gpu::gl::CompilationOptions const&, tflite::gpu::Model<tflite::gpu::TensorRef<tflite::gpu::StrongShape<(tflite::gpu::Layout)10> > > const&, std::unordered_set<int, std::hash<int>, std::equal_to<int>, std::allocator<int> > const&, tflite::gpu::gl::NodeShader const&, tflite::gpu::gl::WorkgroupsCalculator const&, std::unique_ptr<tflite::gpu::gl::CompiledModel, std::default_delete<tflite::gpu::gl::CompiledModel> >*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::ConverterPhwc4ToBhwc::Convert(tflite::gpu::StrongShape<(tflite::gpu::Layout)10> const&, tflite::gpu::gl::GlBuffer const&, tflite::gpu::gl::CommandQueue*, tflite::gpu::gl::GlBuffer*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `glUnmapBuffer'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::BestEffortWorkgroupsCalculator(unsigned char const*, tflite::gpu::GpuInfo const&)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::NewCommandQueue(tflite::gpu::GpuInfo const&)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::RequestGpuInfo(tflite::gpu::GpuInfo*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::ApplyGeneralTransformations(tflite::gpu::ModelTransformer*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::ConvertToPHWC4(absl::Span<float const>, tflite::gpu::StrongShape<(tflite::gpu::Layout)10> const&, absl::Span<float>)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::EglEnvironment::~EglEnvironment()'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `glMapBufferRange'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::GlTexture::~GlTexture()'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::GetSSBOSize(unsigned int, long*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `glBufferData'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `eglGetCurrentContext'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::GlBuffer::~GlBuffer()'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::GlBuffer::GlBuffer(tflite::gpu::gl::GlBuffer&&)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::GetOpenGlErrors()'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::ConvertFromPHWC4(absl::Span<float const>, tflite::gpu::StrongShape<(tflite::gpu::Layout)10> const&, absl::Span<float>)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::EglEnvironment::NewEglEnvironment(std::unique_ptr<tflite::gpu::gl::EglEnvironment, std::default_delete<tflite::gpu::gl::EglEnvironment> >*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::GetOpsToReplace(TfLiteContext*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::BuildModel(TfLiteContext*, TfLiteDelegateParams const*, tflite::gpu::Model<tflite::gpu::TensorRef<tflite::gpu::StrongShape<(tflite::gpu::Layout)10> > >*)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::GetElementsSizeForPHWC4(tflite::gpu::StrongShape<(tflite::gpu::Layout)10> const&)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::GlProgram::~GlProgram()'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `glDeleteBuffers'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::GlBuffer::MakeRef()'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::ObjectManager::RegisterBuffer(unsigned int, tflite::gpu::gl::GlBuffer)'
/usr/bin/ld: /root/code/tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/libgl_delegate.so: undefined reference to `tflite::gpu::gl::ConverterBhwcToPhwc4::Convert(tflite::gpu::StrongShape<(tflite::gpu::Layout)10> const&, tflite::gpu::gl::GlBuffer const&, tflite::gpu::gl::CommandQueue*, tflite::gpu::gl::GlBuffer*)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:13: tflite-sin] Error 1


Martin Wicke

unread,
Feb 20, 2020, 10:32:40 AM2/20/20
to Aaron Boxer, tflite-team, SIG Build

--
To unsubscribe from this group and stop receiving emails from it, send an email to build+un...@tensorflow.org.

Aaron Boxer

unread,
Feb 20, 2020, 11:38:19 AM2/20/20
to Jared Duke, Martin Wicke, tflite-team, SIG Build
Thanks, Jared. I am building tensorflow lite for arm64 Armbian to use with Panfrost driver, which supports EGL 3.1 compute shaders.
I am happy with dynamic library as well - the bazel command also creates an .so file, but this is also missing those symbols.



On Thu, Feb 20, 2020 at 11:25 AM Jared Duke <jdd...@google.com> wrote:
Hi Aaron,

Can you explain more about why you require a static library here, and what your target platform is? In general, bazel doesn't produce self-contained static libraries without a lot of additional massaging. Would the shared (dynamic) library target work for you? Also keep in mind that we only officially support Android for that GPU delegate target.

Jared

--
You received this message because you are subscribed to the Google Groups "tflite-team" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tflite-team...@google.com.
To view this discussion on the web visit https://groups.google.com/a/google.com/d/msgid/tflite-team/CADtzJKPc8Q0UjvPh_JYZrb9VQeyf8%2BR51fMuSUZ91Lr9epXOnQ%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "tensorflow-mobile-eng" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensorflow-mobil...@google.com.
To view this discussion on the web visit https://groups.google.com/a/google.com/d/msgid/tensorflow-mobile-eng/CADtzJKPc8Q0UjvPh_JYZrb9VQeyf8%2BR51fMuSUZ91Lr9epXOnQ%40mail.gmail.com.

Aaron Boxer

unread,
Feb 27, 2020, 9:51:05 AM2/27/20
to Jared Duke, Martin Wicke, tflite-team, SIG Build
Thanks, Jared. We ended up figuring this out - after building and installing mesa master, 

$ meson build -Dgallium-drivers=kmsro,panfrost -Dprefix=/usr -Dbuildtype=debugoptimized -Dbackend=ninja -Dlibdir=/usr/lib/aarch64-linux-gnu/

we used:

$ bazel build --cxxopt="--std=c++11" --copt="-DMESA_EGL_NO_X11_HEADERS -lEGL -lGLESv2" -c opt  tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_gl.so

problem solved!


On Tue, Feb 25, 2020 at 12:22 PM Jared Duke <jdd...@google.com> wrote:
OK, I'll pass this along internally, but it will likely require some non-trivial BUILD refactoring on our end to make this work. If you wouldn't mind filing an issue on GitHub and cc'ing me, we can use that for further discussion and tracking. Thanks!
Reply all
Reply to author
Forward
0 new messages