tensorflow: tf.tile each dimension individual operation not supported

System information

 OS Platform and Distribution : macOS Catalina 10.15.3

TensorFlow installed from : binary

TensorFlow version : 1.15.0

Python version: 3.7.3

Describe the current behavior

I have tensor

a = tf.Tensor( [[[ 16 15 16 15 87] [ 3 4 3 4 87] [ 3 4 8 9 133] [ 3 4 8 9 871] [ 3 4 14 95 87] [ 3 7 9 250 87]] [[ 3 4 3 41 87] [ 3 4 8 93 133] [ 3 4 18 9 87] [ 3 4 141 5 87] [ 3 7 19 25 87] [ 0 0 0 0 0]]], shape=(2, 6, 5), dtype=int64)

b = tf.Tensor( [[[ 1] [2] [ 3] [ 1] [ 2] [2]] [[2] [ 2] [ 2] [ 2] [1] [ 0]]], shape=(2, 6, 1), dtype=int64) Describe the expected behavior

I want vector c such that

[ 16 15 16 15 87] is repeated [1] times , [ 3 4 3 4 87] is repeated [2] times , [ 3 4 8 9 133] is repeated [3] times, [ 3 4 8 9 871] is repated [1] times, [ 3 4 14 95 87] is repeated [2] times, [ 3 7 9 250 87] is repated [2] times and so on …

so c should be

c= tf.Tensor( [[[ 16 15 16 15 87] [ 3 4 3 4 87] [ 3 4 3 4 87] [ 3 4 8 9 133] [ 3 4 8 9 133] [ 3 4 8 9 133] [ 3 4 8 9 871] [ 3 4 14 95 87] [ 3 4 14 95 87] [ 3 7 9 250 87] [ 3 7 9 250 87]] [[ 3 4 3 41 87] [ 3 4 3 41 87] [ 3 4 8 93 133] [ 3 4 8 93 133] [ 3 4 18 9 87] [ 3 4 18 9 87] [ 3 4 141 5 87] [ 3 4 141 5 87] [ 3 7 19 25 87] [ 3 7 19 25 87] [ 0 0 0 0 0]]])

I tried using tf.tile but it only takes same repeation for each dimension .

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 36 (2 by maintainers)

Most upvoted comments

Oops, wrong link - updated.

Glad to hear it! That’s a good question. I think in the first tests a.nested_row_lengths()[0] was returning a Python value, the the loop was being unrolled in Python. Unrolled loops don’t have the shape restrictions of tf.while_loop (they just repeat the graph ops). Once you added the placeholder, the result of that became a Tensor, causing the loop to become a tf.while_loop, which is more restrictive. Anyway, we should have written the loop with tf.range in the first place to avoid that unrolling.

@mdanatg i will try to see if it works in savedmodel in TF 1.15.x and will respond by Tuesday next week max.