Created
March 20, 2017 23:33
-
-
Save SnowMasaya/d5c20bd2b6688383e84f22d1d53249a0 to your computer and use it in GitHub Desktop.
Tensorflow XLAによる高速化、メモリ効率化、サイズの最適化によるポータビリティ向上について ref: http://qiita.com/GushiSnow/items/a373b8d5d904566f65fd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Config to turn on JIT compilation | |
config = tf.ConfigProto() | |
config.graph_options.optimizer_options.global_jit_level = tf.OptimizerOptions.ON_1 | |
sess = tf.Session(config=config) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jit_scope = tf.contrib.compiler.jit.experimental_jit_scope | |
x = tf.placeholder(np.float32) | |
with jit_scope(): | |
y = tf.add(x, x) # The "add" will be compiled with XLA. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with tf.device("/job:localhost/replica:0/task:0/device:XLA_GPU:0"): | |
output = tf.add(input1, input2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment