Skip to content

Instantly share code, notes, and snippets.

@isears
Created February 8, 2021 21:13
Show Gist options
  • Save isears/3005427e65fe01024e79235a95ef203b to your computer and use it in GitHub Desktop.
Save isears/3005427e65fe01024e79235a95ef203b to your computer and use it in GitHub Desktop.
Tensorflow fast XLA histograms
import tensorflow as tf
test_mat = tf.random.uniform(shape=[10, 10, 10, 1], maxval=255, dtype=tf.int32)
hists = tf.math.reduce_sum(
tf.one_hot(test_mat, depth=256, on_value=1, off_value=0, axis=0),
axis=1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment