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
#!/usr/bin/env python | |
r'''Convert an hg-exported patch to a patch suitable for use by git am. | |
>>> hg_patch_to_git_patch(StringIO('# HG changeset patch\n# User Foo <foo@bar.com>\n# Node ID deadbeef\n# Parent cafebabe\nCommit\n\nMsg\n\ndiff -\ndiffdiff')) | |
From: Foo <foo@bar.com> | |
Subject: Commit | |
<BLANKLINE> | |
Msg | |
<BLANKLINE> |
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
// Compile me with -lrt -lpthread -lm. | |
// | |
// To force this program to run on one core, use |taskset 1|. | |
// | |
// See post on http://jlebar.com for why this is relevant. | |
#include <pthread.h> | |
#include <math.h> | |
#include <stdio.h> | |
#include <unistd.h> |
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
#!/usr/bin/env python | |
"""Re-order the files in a patch according to a set of rules. | |
Input is accepted on stdin, and written to stdout. | |
Usage: cat patch | reorder-patch > reordered-patch | |
""" |
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
def model_fn(x, y, z): | |
return tf.reduce_sum(x + y * z) |
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
from tensorflow.contrib.compiler import xla | |
def model_fn(x, y, z): | |
return tf.reduce_sum(x + y * z) | |
def create_and_run_graph(): | |
with tf.Session() as sess: | |
x = tf.placeholder(tf.float32, name='x') | |
y = tf.placeholder(tf.float32, name='y') | |
z = tf.placeholder(tf.float32, name='z') |
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
if should_use_xla(): | |
result = xla.compile(model_fn, (x, y, z))[0] | |
else: | |
result = model_fn(x, y, z) |
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
def model_fn_random_shape(): | |
random_dim_size = tf.random_uniform( | |
shape=[], minval=0, maxval=5, dtype=tf.int32) | |
# Return a vector with a random number of elements, all of them 42.0 | |
return tf.fill([random_dim_size], 42.) | |
def run_random_shapes_model(): | |
with tf.Session() as sess: | |
x = tf.placeholder(tf.float32, name='x') | |
result = xla.compile(model_fn_random_shape)[0] |
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
def model_fn_changing_shapes(x): | |
return 2 * x | |
def run_changing_shapes_model(): | |
with tf.Session() as sess: | |
x = tf.placeholder(tf.float32, name='x') | |
result = xla.compile(model_fn_changing_shapes, (x,))[0] | |
a = sess.run(result, feed_dict={x: [1., 2.]}) | |
b = sess.run(result, feed_dict={x: [1., 2., 3.]}) |
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
def model_fn_unsupported_op(x): | |
return tf.where(tf.cast(x, tf.bool)) |
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
export INSTANCE_NAME="xla-benchmark-8xV100" | |
export IMAGE_FAMILY="tf-1-12-cu100" | |
export PROJECT_NAME="<your project name>" | |
gcloud beta compute instances create $INSTANCE_NAME \ | |
--project=$PROJECT_NAME \ | |
--machine-type=n1-standard-64 \ | |
--maintenance-policy=TERMINATE \ | |
--accelerator=type=nvidia-tesla-v100,count=8 \ | |
--tags=http-server,https-server \ |
OlderNewer