{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19233","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19233/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19233/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19233/events","html_url":"https://github.com/tensorflow/tensorflow/issues/19233","id":322439961,"node_id":"MDU6SXNzdWUzMjI0Mzk5NjE=","number":19233,"title":"`foldl` disallows mixing different types of `elems`","user":{"login":"shengc","id":940628,"node_id":"MDQ6VXNlcjk0MDYyOA==","avatar_url":"https://avatars1.githubusercontent.com/u/940628?v=4","gravatar_id":"","url":"https://api.github.com/users/shengc","html_url":"https://github.com/shengc","followers_url":"https://api.github.com/users/shengc/followers","following_url":"https://api.github.com/users/shengc/following{/other_user}","gists_url":"https://api.github.com/users/shengc/gists{/gist_id}","starred_url":"https://api.github.com/users/shengc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shengc/subscriptions","organizations_url":"https://api.github.com/users/shengc/orgs","repos_url":"https://api.github.com/users/shengc/repos","events_url":"https://api.github.com/users/shengc/events{/privacy}","received_events_url":"https://api.github.com/users/shengc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"aselle","id":326106,"node_id":"MDQ6VXNlcjMyNjEwNg==","avatar_url":"https://avatars1.githubusercontent.com/u/326106?v=4","gravatar_id":"","url":"https://api.github.com/users/aselle","html_url":"https://github.com/aselle","followers_url":"https://api.github.com/users/aselle/followers","following_url":"https://api.github.com/users/aselle/following{/other_user}","gists_url":"https://api.github.com/users/aselle/gists{/gist_id}","starred_url":"https://api.github.com/users/aselle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aselle/subscriptions","organizations_url":"https://api.github.com/users/aselle/orgs","repos_url":"https://api.github.com/users/aselle/repos","events_url":"https://api.github.com/users/aselle/events{/privacy}","received_events_url":"https://api.github.com/users/aselle/received_events","type":"User","site_admin":false},"assignees":[{"login":"aselle","id":326106,"node_id":"MDQ6VXNlcjMyNjEwNg==","avatar_url":"https://avatars1.githubusercontent.com/u/326106?v=4","gravatar_id":"","url":"https://api.github.com/users/aselle","html_url":"https://github.com/aselle","followers_url":"https://api.github.com/users/aselle/followers","following_url":"https://api.github.com/users/aselle/following{/other_user}","gists_url":"https://api.github.com/users/aselle/gists{/gist_id}","starred_url":"https://api.github.com/users/aselle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aselle/subscriptions","organizations_url":"https://api.github.com/users/aselle/orgs","repos_url":"https://api.github.com/users/aselle/repos","events_url":"https://api.github.com/users/aselle/events{/privacy}","received_events_url":"https://api.github.com/users/aselle/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-05-11T21:27:49Z","updated_at":"2018-06-10T21:56:17Z","closed_at":null,"author_association":"NONE","body":"### System information\r\n- **Have I written custom code (as opposed to using a stock example script provided in TensorFlow)**:\r\nyes\r\n- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:\r\nLinux Redhat\r\n- **TensorFlow installed from (source or binary)**:\r\nconda-forge\r\n- **TensorFlow version (use command below)**:\r\n1.6\r\n- **Python version**: \r\n3.6\r\n- **Bazel version (if compiling from source)**:\r\nN/A\r\n- **GCC/Compiler version (if compiling from source)**:\r\nN/A\r\n- **CUDA/cuDNN version**:\r\nN/A (cpu only)\r\n- **GPU model and memory**:\r\nN/A (cpu only)\r\n- **Exact command to reproduce**:\r\n### Describe the problem\r\n### Source code / logs\r\nLook at the following two code snippets. \r\n\r\n```python\r\nscore = tf.foldl(lambda s, x: transitions[x[0], x[1]] + x[2][x[0]] + s, (label[1:], label[:-1], logits), initializer=np.zeros((), dtype=np.float64))\r\n```\r\n\r\n```python\r\nscore = tf.reduce_sum(tf.map_fn(lambda x: transitions[x[0], x[1]] + x[2][x[0]], (label[1:], label[:-1], logits), dtype=tf.float64))\r\n```\r\n\r\nLong story short, the 1st one does not compile, while the second one does. From my view, these 2 operations essentially do the same thing. That said, from the error trace, it seems to me `foldl` disallows mixing different types for the argument of `elems=`, since indeed `label` is of type `tf.int32`, while `logits` is of type `tf.float64`. However the documentation does not indicate that is the case. Could you confirm if that is true ? If yes, can we update the documentation to make it explicit ?\r\n\r\n```python\r\nXXX/lib/python3.6/site-packages/tensorflow/python/ops/functional_ops.py in foldl(fn, elems, initializer, parallel_iterations, back_prop, swap_memory, name)\r\n    107 \r\n    108     # Convert elems to tensor array.\r\n--> 109     elems = ops.convert_to_tensor(elems, name=\"elems\")\r\n    110     n = array_ops.shape(elems)[0]\r\n    111     elems_ta = tensor_array_ops.TensorArray(dtype=elems.dtype, size=n,\r\n\r\nXXX/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in convert_to_tensor(value, dtype, name, preferred_dtype)\r\n    944       name=name,\r\n    945       preferred_dtype=preferred_dtype,\r\n--> 946       as_ref=False)\r\n    947 \r\n    948 \r\n\r\nXXX/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx)\r\n   1034 \r\n   1035     if ret is None:\r\n-> 1036       ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)\r\n   1037 \r\n   1038     if ret is NotImplemented:\r\n\r\nXXX/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py in _autopacking_conversion_function(v, dtype, name, as_ref)\r\n   1018   if dtype is not None and dtype != inferred_dtype:\r\n   1019     return NotImplemented\r\n-> 1020   return _autopacking_helper(v, inferred_dtype, name or \"packed\")\r\n   1021 \r\n   1022 \r\n\r\nXXX/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py in _autopacking_helper(list_or_tuple, dtype, name)\r\n    960           raise TypeError(\"Cannot convert a list containing a tensor of dtype \"\r\n    961                           \"%s to %s (Tensor is: %r)\" % (elem.dtype, dtype,\r\n--> 962                                                         elem))\r\n    963         converted_elems.append(elem)\r\n    964         must_pack = True\r\n\r\nTypeError: Cannot convert a list containing a tensor of dtype <dtype: 'float64'> to <dtype: 'int32'> (Tensor is: <tf.Tensor 'loss/BiasAdd:0' shape=(?, 5) dtype=float64>)\r\n```"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/396085134","html_url":"https://github.com/tensorflow/tensorflow/issues/19233#issuecomment-396085134","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19233","id":396085134,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NjA4NTEzNA==","user":{"login":"tensorflowbutler","id":28546240,"node_id":"MDQ6VXNlcjI4NTQ2MjQw","avatar_url":"https://avatars2.githubusercontent.com/u/28546240?v=4","gravatar_id":"","url":"https://api.github.com/users/tensorflowbutler","html_url":"https://github.com/tensorflowbutler","followers_url":"https://api.github.com/users/tensorflowbutler/followers","following_url":"https://api.github.com/users/tensorflowbutler/following{/other_user}","gists_url":"https://api.github.com/users/tensorflowbutler/gists{/gist_id}","starred_url":"https://api.github.com/users/tensorflowbutler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tensorflowbutler/subscriptions","organizations_url":"https://api.github.com/users/tensorflowbutler/orgs","repos_url":"https://api.github.com/users/tensorflowbutler/repos","events_url":"https://api.github.com/users/tensorflowbutler/events{/privacy}","received_events_url":"https://api.github.com/users/tensorflowbutler/received_events","type":"User","site_admin":false},"created_at":"2018-06-10T21:56:16Z","updated_at":"2018-06-10T21:56:16Z","author_association":"MEMBER","body":"Nagging Assignee @aselle: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly."}}
{"actor":{"display_login":"tensorflowbutler"}}