Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Update README.md compile instructions to match adding_an_op.
from [adding_an_op](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/docs_src/extend/adding_an_op.md).

Tested: compiled using the modified instructions and ran `python word2vec_optimized_test.py`.

Fixes tensorflow/tensorflow#14620
  • Loading branch information
MarkDaoust authored Jan 3, 2018
1 parent 8e4a1e2 commit 61bb943
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tutorials/embedding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ unzip -p source-archive.zip word2vec/trunk/questions-words.txt > questions-word
rm text8.zip source-archive.zip
```

You will need to compile the ops as follows:
You will need to compile the ops as follows (See
[Adding a New Op to TensorFlow](https://www.tensorflow.org/how_tos/adding_an_op/#building_the_op_library)
for more details).:

```shell
TF_INC=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
g++ -std=c++11 -shared word2vec_ops.cc word2vec_kernels.cc -o word2vec_ops.so -fPIC -I $TF_INC -O2 -D_GLIBCXX_USE_CXX11_ABI=0
TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )
g++ -std=c++11 -shared word2vec_ops.cc word2vec_kernels.cc -o word2vec_ops.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2 -D_GLIBCXX_USE_CXX11_ABI=0
```

On Mac, add `-undefined dynamic_lookup` to the g++ command.

(For an explanation of what this is doing, see the tutorial on [Adding a New Op to TensorFlow](https://www.tensorflow.org/how_tos/adding_an_op/#building_the_op_library). The flag `-D_GLIBCXX_USE_CXX11_ABI=0` is included to support newer versions of gcc. However, if you compiled TensorFlow from source using gcc 5 or later, you may need to exclude the flag.)
(The flag `-D_GLIBCXX_USE_CXX11_ABI=0` is included to support newer versions of gcc. However, if you compiled TensorFlow from source using gcc 5 or later, you may need to exclude the flag.)
Then run using:

```shell
Expand Down

0 comments on commit 61bb943

Please sign in to comment.