Skip to content

[master] User op example doesn't work #1569

@rlrs

Description

@rlrs

A recent change to remove the static linking in user ops seems to have broken them.
From the example:
g++ -std=c++11 -shared zero_out.cc -o zero_out.so -I $TF_INC
you need -fPIC to compile it:
/usr/bin/ld: /tmp/ccvknfY4.o: relocation R_X86_64_32 against '.text' can not be used when making a shared object; recompile with -fPIC

It used to be:

g++ -std=c++11 -shared zero_out.cc -o zero_out.so \
-I $TF_INC -l tensorflow_framework -L $TF_LIB \
-fPIC -Wl,-rpath $TF_LIB

which no longer works since tensorflow_framework was removed.

However, it builds just by adding -fPIC, and you can try to load it:
tf.load_op_library('zero_out.so')
resulting in:
undefined symbol: _ZN10tensorflow8internal21CheckOpMessageBuilder9NewStringB5cxx11Ev

(and on a minor note, the doc link to load_op_library is broken, it's missing a '.html')

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions