I'm trying to modify Tensorflow source code (core).
After study the code I started to modify, recompile and run my own tests. But I'm not sure if I'm doing it in the best way possible. So I have some questions about it.
1 - Do I need to recompile all the tensorflow code or only the modified module?
2 - To implement the modification, have I always to create a wheel package from my sources and install it? Why I can integrate the modification directly after the bazel compilation?
3 - What is the best way to test the code? There is a lot of units test and I don't know how use its properly.
4 - I'm using bash scripts for linux to run bazel commands, there is something better?
Thanks everybody!
(Summarizing from comments on the question)
There is no need to build a pip package for TensorFlow while developing changes to TensorFlow itself. Instead, bazel run <target>
lets you run a unit test (bazel test
will log the output of one or more tests to a file rather than printing it directly). So for example if you're modifying the one hot op (tensorflow/core/kernels/one_hot_op.cc), you might want to run the Python unit test suit for that op (tensorflow/python/kernel_tests/one_hot_op_test.py):
bazel run //tensorflow/python/kernel_tests:one_hot_op_test
Or go to the directory and use a relative build target:
cd python/kernel_tests
bazel run :one_hot_op_test
Test targets are defined in BUILD files. Any changes to dependencies should be picked up automatically. After the first run, compilation should be quite snappy, as most of it will be cached.
If you're developing changes which will eventually be integrated into software which uses TensorFlow, it's likely going to be a more pleasant experience if you first unit test the TensorFlow changes before moving on to integration testing (where you'll e.g. bundle up TensorFlow into a pip package).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With