{"action":"reopened","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19497","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19497/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19497/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/19497/events","html_url":"https://github.com/tensorflow/tensorflow/issues/19497","id":325666823,"number":19497,"title":"NHWC convolution sometimes incorrectly considered NCHW","user":{"login":"tdanyluk","id":9149812,"avatar_url":"https://avatars1.githubusercontent.com/u/9149812?v=4","gravatar_id":"","url":"https://api.github.com/users/tdanyluk","html_url":"https://github.com/tdanyluk","followers_url":"https://api.github.com/users/tdanyluk/followers","following_url":"https://api.github.com/users/tdanyluk/following{/other_user}","gists_url":"https://api.github.com/users/tdanyluk/gists{/gist_id}","starred_url":"https://api.github.com/users/tdanyluk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdanyluk/subscriptions","organizations_url":"https://api.github.com/users/tdanyluk/orgs","repos_url":"https://api.github.com/users/tdanyluk/repos","events_url":"https://api.github.com/users/tdanyluk/events{/privacy}","received_events_url":"https://api.github.com/users/tdanyluk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-05-23T11:39:39Z","updated_at":"2018-05-25T09:51:43Z","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)**: yes\r\n- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:  Linux Ubuntu 16.04\r\n- **TensorFlow installed from (source or binary)**: binary\r\n- **TensorFlow version (use command below)**: 1.7.0\r\n- **Python version**:  3.5.2\r\n- **Bazel version (if compiling from source)**:\r\n- **GCC/Compiler version (if compiling from source)**:\r\n- **CUDA/cuDNN version**:  9.0.176 / 7.0.5\r\n- **GPU model and memory**: GeForce GTX 1050 Ti/PCIe/SSE2 4GB\r\n- **Exact command to reproduce**: custom script\r\n\r\n### Describe the problem\r\nWhen using dilated conv2d and bias_add, the conv2d is incorrectly considered NCHW, so the normal dilation format is not accepted. Strangely when there is no bias_add, the problem does not happen.\r\n\r\n### Source code / logs\r\nThis gives ERROR:\r\n```\r\nimport tensorflow as tf \r\nimport numpy as np\r\n\r\ndef test_add_conv_transform1():\r\n    input_ = tf.placeholder(tf.float32, shape=[1, 64, 64, 3], name=\"input\")\r\n    filter_ = tf.get_variable(dtype=tf.float32, shape=[4, 4, 3, 16], name=\"filter\")\r\n    \r\n    conv = tf.nn.conv2d(input_, filter_, strides=[1, 1, 1, 1], padding='VALID', dilations=[1, 4, 4, 1])\r\n\r\n    bias1 = tf.get_variable(name='bias', shape=[16], dtype=tf.float32)\r\n    return tf.nn.bias_add(conv, bias1)\r\n        \r\no = test_add_conv_transform1()\r\nwith tf.Session() as sess:\r\n    init = tf.global_variables_initializer()\r\n    sess.run(init)\r\n    sess.run(o, {\"input:0\": np.random.random([1, 64, 64, 3])})\r\n```\r\n\r\ntensorflow.python.framework.errors_impl.InvalidArgumentError: Current implementation does not yet support dilations in the batch and depth dimensions.\r\n         [[Node: Conv2D = Conv2D[T=DT_FLOAT, data_format=\"NCHW\", dilations=[1, 4, 4, 1], padding=\"VALID\", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device=\"/job:localhost/replica:0/task:0/device:GPU:0\"](Conv2D-0-TransposeNHWCToNCHW-LayoutOptimizer, filter/read)]]\r\n\r\nInterestingly this works as intended:\r\n```\r\nimport tensorflow as tf \r\nimport numpy as np\r\n\r\ndef test_add_conv_transform1():\r\n    input_ = tf.placeholder(tf.float32, shape=[1, 64, 64, 3], name=\"input\")\r\n    filter_ = tf.get_variable(dtype=tf.float32, shape=[4, 4, 3, 16], name=\"filter\")\r\n\r\n    return tf.nn.conv2d(input_, filter_, strides=[1, 1, 1, 1], padding='VALID', dilations=[1, 4, 4, 1])\r\n        \r\no = test_add_conv_transform1()\r\nwith tf.Session() as sess:\r\n    init = tf.global_variables_initializer()\r\n    sess.run(init)\r\n    sess.run(o, {\"input:0\": np.random.random([1, 64, 64, 3])})\r\n```\r\n"}}
{"actor":{"display_login":"tdanyluk"}}