Skip to content

Commit 1b18a7e

Browse files
author
Johannes Ballé
committed
Import coder_ops from tf.contrib everywhere, plus some cosmetics.
1 parent 034d8ac commit 1b18a7e

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ The layer implements a flexible probability density model to estimate entropy,
4646
which is described in the appendix of the paper (please cite the paper if you
4747
use this code for scientific work):
4848

49+
> J. Ballé, D. Minnen, S. Singh, S. J. Hwang, N. Johnston:
4950
> "Variational image compression with a scale hyperprior"
50-
> Johannes Ballé, David Minnen, Saurabh Singh, Sung Jin Hwang, Nick Johnston
5151
> https://arxiv.org/abs/1802.01436
5252
5353
The layer assumes that the input tensor is at least 2D, with a batch dimension

compression/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@
2121

2222
# pylint: disable=wildcard-import
2323
from compression.python.layers.entropybottleneck import *
24-
from compression.python.ops.coder_ops import *
24+
# TODO(jonycgn,nmjohn): revert to importing from here once we figure out why the
25+
# nightlies don't work.
26+
# from compression.python.ops.coder_ops import *
27+
from tensorflow.contrib.coder.python.ops.coder_ops import *
2528
# pylint: enable=wildcard-import
2629

2730
from tensorflow.python.util.all_util import remove_undocumented
28-
remove_undocumented(__name__)
31+
remove_undocumented(__name__, [
32+
"EntropyBottleneck",
33+
"pmf_to_quantized_cdf", "range_decode", "range_encode",
34+
])

compression/compile.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.ge
2222
OPTIONAL_MAC_FLAG=''
2323

2424
if [ "$uname" == "Darwin" ]; then
25-
OPTIONAL_MAC_FLAG='-undefined dynamic_lookup'
25+
OPTIONAL_MAC_FLAG='-undefined dynamic_lookup'
2626
fi
2727

28-
g++ -std=c++11 -shared kernels/pmf_to_cdf_op.cc kernels/range_coder.cc kernels/range_coder_ops.cc kernels/range_coder_ops_util.cc ops/coder_ops.cc -o _coder_ops.so -fPIC ${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2 ${OPTIONAL_MAC_FLAG}
28+
g++ -std=c++11 -shared \
29+
kernels/pmf_to_cdf_op.cc \
30+
kernels/range_coder.cc \
31+
kernels/range_coder_ops.cc \
32+
kernels/range_coder_ops_util.cc \
33+
ops/coder_ops.cc \
34+
-o _coder_ops.so -fPIC \
35+
${TF_CFLAGS[@]} ${TF_LFLAGS[@]} -O2 ${OPTIONAL_MAC_FLAG}

compression/python/ops/coder_ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
from __future__ import print_function
2121

2222
import os
23-
2423
import tensorflow as tf
2524

2625

27-
_coder_ops = tf.load_op_library(os.path.join(tf.resource_loader.get_data_files_path(), "../../_coder_ops.so"))
26+
_coder_ops = tf.load_op_library(os.path.join(
27+
tf.resource_loader.get_data_files_path(), "../../_coder_ops.so"))
2828

2929
# TODO(nmjohn): Find a way to do the below mapping in this module automatically.
3030
pmf_to_quantized_cdf = _coder_ops.pmf_to_quantized_cdf

0 commit comments

Comments
 (0)