Skip to content

Commit

Permalink
Part 2b of renaming SparseTensor.shape -> SparseTensor.dense_shape
Browse files Browse the repository at this point in the history
Change: 140811785
  • Loading branch information
ebrevdo authored and tensorflower-gardener committed Dec 2, 2016
1 parent d06d93d commit 0aa14fa
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion tensorflow/python/kernel_tests/control_flow_ops_py_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def testCondSparseTensor(self):
x = tf.SparseTensor(indices, values, shape=shape)
pred = tf.less(1, 2)
fn1 = lambda: tf.SparseTensor(indices + 1, x.values + 1, shape=shape)
fn2 = lambda: tf.SparseTensor(indices, x.values - 1, shape=shape)
fn2 = lambda: tf.SparseTensor(indices, x.values - 1, dense_shape=shape)
r = tf.cond(pred, fn1, fn2)
self.assertAllEqual([3.0, 5.0], r.values.eval())
self.assertAllEqual([[1], [4]], r.indices.eval())
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/kernel_tests/cwise_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _sparsify(x, thresh=0.5, index_dtype=np.int64):
x_shape = x.shape

return tf.SparseTensor(
indices=x_indices, values=x_values, shape=x_shape), x_values
indices=x_indices, values=x_values, dense_shape=x_shape), x_values

class UnaryOpTest(tf.test.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/kernel_tests/functional_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def testMapSparseTensor(self):
with self.assertRaises(TypeError):
tf.map_fn(lambda x: x, tf.SparseTensor(indices=[[0, 0], [0, 1], [1, 0]],
values=tf.constant([0, 1, 2]),
shape=[2, 2]))
dense_shape=[2, 2]))

def testMap_Scoped(self):
with self.test_session() as sess:
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/kernel_tests/shape_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _sparsify(x, thresh=0.5, index_dtype=np.int64):
x_shape = x.shape

return tf.SparseTensor(
indices=x_indices, values=x_values, shape=x_shape), len(x_values)
indices=x_indices, values=x_values, dense_shape=x_shape), len(x_values)

class ShapeOpsTest(tf.test.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/kernel_tests/sparse_add_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _sparsify(x, thresh=0.5, index_dtype=np.int64):
x_shape = x.shape

return tf.SparseTensor(
indices=x_indices, values=x_values, shape=x_shape), len(x_values)
indices=x_indices, values=x_values, dense_shape=x_shape), len(x_values)


class SparseAddTest(tf.test.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/kernel_tests/sparse_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _sparsify(x, thresh=0.5, index_dtype=np.int64):
x_shape = x.shape

return tf.SparseTensor(
indices=x_indices, values=x_values, shape=x_shape), len(x_values)
indices=x_indices, values=x_values, dense_shape=x_shape), len(x_values)


class SparseToIndicatorTest(test_util.TensorFlowTestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _sparsify(self, x):
x_shape = x.shape

return tf.SparseTensor(
indices=x_indices, values=x_values, shape=x_shape), len(x_values)
indices=x_indices, values=x_values, dense_shape=x_shape), len(x_values)

def _randomTensor(self, size, np_dtype, adjoint=False, sparse=False):
n, m = size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _testMatmul(self, x, y, adjoint_a=False, adjoint_b=False):

with self.test_session(use_gpu=True):
sp_x_value = tf.SparseTensorValue(
indices=x_indices, values=x_values, shape=x_shape)
indices=x_indices, values=x_values, dense_shape=x_shape)
tf_value_ans = sparse_ops.sparse_tensor_dense_matmul(
sp_x_value, y, adjoint_a=adjoint_a, adjoint_b=adjoint_b)
tf_tensor_ans = sparse_ops.sparse_tensor_dense_matmul(
Expand Down
16 changes: 8 additions & 8 deletions tensorflow/python/ops/math_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ def abs(x, name=None):
x_abs = gen_math_ops.complex_abs(
x.values, Tout=x.values.dtype.real_dtype, name=name)
return sparse_tensor.SparseTensor(
indices=x.indices, values=x_abs, shape=x.shape)
indices=x.indices, values=x_abs, dense_shape=x.shape)
x_abs = gen_math_ops._abs(x.values, name=name)
return sparse_tensor.SparseTensor(
indices=x.indices, values=x_abs, shape=x.shape)
indices=x.indices, values=x_abs, dense_shape=x.shape)
else:
x = ops.convert_to_tensor(x, name="x")
if x.dtype in (dtypes.complex64, dtypes.complex128):
Expand Down Expand Up @@ -335,7 +335,7 @@ def neg(x, name=None):
if isinstance(x, sparse_tensor.SparseTensor):
x_neg = gen_math_ops.neg(x.values, name=name)
return sparse_tensor.SparseTensor(
indices=x.indices, values=x_neg, shape=x.shape)
indices=x.indices, values=x_neg, dense_shape=x.shape)
else:
return gen_math_ops.neg(x, name=name)

Expand All @@ -359,7 +359,7 @@ def sign(x, name=None):
if isinstance(x, sparse_tensor.SparseTensor):
x_sign = gen_math_ops.sign(x.values, name=name)
return sparse_tensor.SparseTensor(
indices=x.indices, values=x_sign, shape=x.shape)
indices=x.indices, values=x_sign, dense_shape=x.shape)
else:
return gen_math_ops.sign(x, name=name)

Expand All @@ -381,7 +381,7 @@ def square(x, name=None):
if isinstance(x, sparse_tensor.SparseTensor):
x_square = gen_math_ops.square(x.values, name=name)
return sparse_tensor.SparseTensor(
indices=x.indices, values=x_square, shape=x.shape)
indices=x.indices, values=x_square, dense_shape=x.shape)
else:
return gen_math_ops.square(x, name=name)

Expand All @@ -403,7 +403,7 @@ def sqrt(x, name=None):
if isinstance(x, sparse_tensor.SparseTensor):
x_sqrt = gen_math_ops.sqrt(x.values, name=name)
return sparse_tensor.SparseTensor(
indices=x.indices, values=x_sqrt, shape=x.shape)
indices=x.indices, values=x_sqrt, dense_shape=x.shape)
else:
return gen_math_ops.sqrt(x, name=name)

Expand All @@ -423,7 +423,7 @@ def erf(x, name=None):
if isinstance(x, sparse_tensor.SparseTensor):
x_erf = gen_math_ops.erf(x.values, name=name)
return sparse_tensor.SparseTensor(
indices=x.indices, values=x_erf, shape=x.shape)
indices=x.indices, values=x_erf, dense_shape=x.shape)
else:
return gen_math_ops.erf(x, name=name)

Expand Down Expand Up @@ -1997,7 +1997,7 @@ def tanh(x, name=None):
if isinstance(x, sparse_tensor.SparseTensor):
x_tanh = gen_math_ops._tanh(x.values, name=name)
return sparse_tensor.SparseTensor(
indices=x.indices, values=x_tanh, shape=x.shape)
indices=x.indices, values=x_tanh, dense_shape=x.shape)
else:
return gen_math_ops._tanh(x, name=name)

Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/ops/parsing_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def parse_example(serialized, features, name=None, example_names=None):
```
{"ft": SparseTensor(indices=[[0, 0], [0, 1], [2, 0]],
values=[1.0, 2.0, 3.0],
shape=(3, 2)) }
dense_shape=(3, 2)) }
```
Given two `Example` input protos in `serialized`:
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/ops/sparse_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ def sparse_merge(sp_ids, sp_values, vocab_size, name=None,
```python
SparseTensor(indices=[[0, 0], [1, 1], [1, 3], [1, 4], [2, 0], [2, 3]],
values=[-3, 1, 4, 1, 5, 9],
shape=[3, 6])
dense_shape=[3, 6])
```
Args:
Expand Down
20 changes: 10 additions & 10 deletions tensorflow/python/training/input_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,13 +700,13 @@ def testCannotInferRankError(self):
tf.train.batch([x], batch_size=2)

def testBatchedSparseTensorInferredShape(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.batch([sparse], batch_size=2)
self.assertAllEqual((2,), batched.shape.get_shape().as_list())

def testBatchedSparseTensorInferredShapeEnqueueMany(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.batch([sparse], batch_size=2, enqueue_many=True)
self.assertAllEqual((1,), batched.shape.get_shape().as_list())
Expand Down Expand Up @@ -779,13 +779,13 @@ def testMultipleThreadKeepInputEnqueueMany(self):
self._testKeepInputHelper(5, True)

def testMaybeBatchedSparseTensorInferredShape(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.maybe_batch([sparse], keep_input=True, batch_size=2)
self.assertAllEqual((2,), batched.shape.get_shape().as_list())

def testMaybeBatchedSparseTensorInferredShapeEnqueueMany(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.maybe_batch(
[sparse], keep_input=True, batch_size=2, enqueue_many=True)
Expand Down Expand Up @@ -1248,14 +1248,14 @@ def testMultipleThreadKeepInputEnqueueMany(self):
self._testKeepInputHelper(5, True)

def testMaybeBatchedSparseTensorInferredShape(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.maybe_batch_join(
[[sparse]], keep_input=True, batch_size=2)
self.assertAllEqual((2,), batched.shape.get_shape().as_list())

def testMaybeBatchedSparseTensorInferredShapeEnqueueMany(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.maybe_batch_join(
[[sparse]], keep_input=True, batch_size=2, enqueue_many=True)
Expand Down Expand Up @@ -1553,13 +1553,13 @@ def testMultipleThreadKeepInputEnqueueMany(self):
self._testKeepInputHelper(5, True)

def testMaybeBatchedSparseTensorInferredShape(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.maybe_shuffle_batch([sparse], 2, 10, 1, True)
self.assertAllEqual((2,), batched.shape.get_shape().as_list())

def testMaybeBatchedSparseTensorInferredShapeEnqueueMany(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.maybe_shuffle_batch(
[sparse], 2, 10, 1, True, enqueue_many=True)
Expand Down Expand Up @@ -1860,13 +1860,13 @@ def testMultipleThreadKeepInputEnqueueMany(self):
self._testKeepInputHelper(5, True)

def testMaybeBatchedSparseTensorInferredShape(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.maybe_shuffle_batch_join([[sparse]], 2, 10, 1, True)
self.assertAllEqual((2,), batched.shape.get_shape().as_list())

def testMaybeBatchedSparseTensorInferredShapeEnqueueMany(self):
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], shape=[1])
sparse = tf.SparseTensor(indices=[[0]], values=[1.0], dense_shape=[1])
self.assertAllEqual((1,), sparse.shape.get_shape().as_list())
batched = tf.train.maybe_shuffle_batch_join(
[[sparse]], 2, 10, 1, True, enqueue_many=True)
Expand Down

0 comments on commit 0aa14fa

Please sign in to comment.