Skip to content

Commit

Permalink
Fixing a bug in MixedBlockCompressionOp.
Browse files Browse the repository at this point in the history
Renamed qrn_compression_factor to just compression_factor and qrn_num_bases to num_bases.
Removed references to theta_fn in calls to CreateVariable inside customized_apply_compression_op.

PiperOrigin-RevId: 400883620
  • Loading branch information
nishanthd-google authored and copybara-github committed Oct 5, 2021
1 parent e02792e commit 6de7b9c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions graph_compression/compression_lib/compression_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1984,8 +1984,8 @@ def get_customized_apply_compression_op(self,
self.matrix_compressor = matrix_compressor
with tf.variable_scope(scope) as scope:
# block_matrices is a rank 3 tensor of shape [m, n, num_blocks]
num_blocks = self._spec.qrn_compression_factor
num_bases = self._spec.qrn_num_bases
num_blocks = self._spec.compression_factor
num_bases = self._spec.num_bases
block_matrices_pc = weight_params_fn([
shape[0] // num_blocks,
shape[1] // num_blocks,
Expand All @@ -2002,12 +2002,10 @@ def get_customized_apply_compression_op(self,
layer_obj.CreateVariable(
'block_matrices',
block_matrices_pc,
theta_fn=None,
trainable=True)
layer_obj.CreateVariable(
'linear_mixer',
linear_mixer_pc,
theta_fn=None,
trainable=True)

self.block_matrices = layer_obj.vars.block_matrices
Expand Down Expand Up @@ -2096,8 +2094,8 @@ def get_mix_operator(self, theta, concat):
# turned out to be worse for latency than writing out the matmul/einsum
# using a loop. Hence we implement the latter strategy here.

num_blocks = self._spec.qrn_compression_factor
num_bases = self._spec.qrn_num_bases
num_blocks = self._spec.compression_factor
num_bases = self._spec.num_bases

# block the concat tensor into num_blocks
blocked_input = tf.reshape(concat, [
Expand Down Expand Up @@ -2161,8 +2159,8 @@ def get_matmul_operator(self,
# Performing einsum or a matmul with such a small tensor on TPUs
# turned out to be worse for latency than writing out the matmul/einsum
# using a loop. Hence we implement the latter strategy here.
num_blocks = self._spec.qrn_compression_factor
num_bases = self._spec.qrn_num_bases
num_blocks = self._spec.compression_factor
num_bases = self._spec.num_bases

# block the inputs tensor into num_blocks
blocked_input = tf.reshape(inputs, [
Expand Down Expand Up @@ -2218,8 +2216,8 @@ def get_einsum_operator(self, inputs, layerobj):
# turned out to be worse for latency than writing out the matmul/einsum
# using a loop. Hence we implement the latter strategy here.
theta = layerobj.theta
num_blocks = self._spec.qrn_compression_factor
num_bases = self._spec.qrn_num_bases
num_blocks = self._spec.compression_factor
num_bases = self._spec.num_bases

# block the inputs tensor into num_blocks
blocked_input = tf.reshape(inputs, [
Expand Down

0 comments on commit 6de7b9c

Please sign in to comment.