<p dir="auto">I understand TensorFlow only supports CUDA. What would need to be done to add in OpenCL support?</p>
<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes</li>
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux version 3.10.0-957.10.1.el7.x86_64 (<a href="mailto:mockbuild@x86-040.build.eng.bos.redhat.com">mockbuild@x86-040.build.eng.bos.redhat.com</a>) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) )</li>
<li>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A</li>
<li>TensorFlow installed from (source or binary): binary pip install</li>
<li>TensorFlow version (use command below): v1.13.1-0-g6612da8951 1.13.1</li>
<li>Python version: 3.6.4</li>
<li>Bazel version (if compiling from source): N/A</li>
<li>GCC/Compiler version (if compiling from source): N/A</li>
<li>CUDA/cuDNN version: N/A (CPU)</li>
<li>GPU model and memory: N/A (CPU)</li>
</ul>
<p dir="auto"><strong>Describe the current behavior</strong><br>
Error occurs when trying to compute the Jacobian in the following code</p>
<p dir="auto"><strong>Describe the expected behavior</strong><br>
&lt;tf.Tensor: id=XXX, shape=(2, 1), dtype=float32, numpy=array([[1.], [1.]], dtype=float32)&gt;</p>
<p dir="auto"><strong>Code to reproduce the issue</strong><br>
Provide a reproducible test case that is the bare minimum necessary to generate the problem.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import tensorflow as tf
tf.enable_eager_execution()

with tf.GradientTape() as g:
    x  = tf.constant([1.0])
    g.watch(x)
    y = tf.concat([x,x], axis=0)

g.jacobian(y, x)"><pre class="notranslate"><code class="notranslate">import tensorflow as tf
tf.enable_eager_execution()

with tf.GradientTape() as g:
    x  = tf.constant([1.0])
    g.watch(x)
    y = tf.concat([x,x], axis=0)

g.jacobian(y, x)
</code></pre></div>
<p dir="auto"><strong>Other info / logs</strong><br>
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.</p>
<p dir="auto">Additional info: the expected behavior occurs when creating the <code class="notranslate">GradientTape</code> with <code class="notranslate">persistent=True</code> and replacing the last line of code with <code class="notranslate">g.jacobian(y, x, experimental_use_pfor=False)</code>. However, that workaround is extremely slow with real data.</p>
<h2 dir="auto">Log of the code that reproduces the issue:</h2>
<p dir="auto">AttributeError                            Traceback (most recent call last)<br>
 in ()<br>
9 #     y = tf.concat([y,y], axis=0)<br>
10<br>
---&gt; 11 g.jacobian(y, x)</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/eager/backprop.py in jacobian(self, target, sources, unconnected_gradients, parallel_iterations, experimental_use_pfor)<br>
1021       try:<br>
1022         output = pfor_ops.pfor(loop_fn, target_size,<br>
-&gt; 1023                                parallel_iterations=parallel_iterations)<br>
1024       except ValueError as err:<br>
1025         six.reraise(</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/parallel_for/control_flow_ops.py in pfor(loop_fn, iters, parallel_iterations)<br>
149   if context.executing_eagerly():<br>
150     f = function.defun(f)<br>
--&gt; 151   return f()<br>
152<br>
153</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/eager/function.py in <strong>call</strong>(self, *args, **kwargs)<br>
862   def <strong>call</strong>(self, *args, **kwargs):<br>
863     """Calls a graph function specialized to the inputs."""<br>
--&gt; 864     graph_function, args, kwargs = self._maybe_define_function(args, kwargs)<br>
865     return graph_function._filtered_call(args, kwargs)  # pylint: disable=protected-access<br>
866</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/eager/function.py in _maybe_define_function(self, args, kwargs)<br>
1174                 self._input_signature,<br>
1175                 autograph=self._autograph,<br>
-&gt; 1176                 arg_names=arg_names),<br>
1177             self._function_attributes)<br>
1178         if self._input_signature:</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py in func_graph_from_py_func(name, python_func, args, kwargs, signature, func_graph, autograph, add_control_dependencies, arg_names, op_return_value)<br>
446         tf_decorator.rewrap(python_func, original_func, converted_func)<br>
447<br>
--&gt; 448       func_outputs = python_func(*func_args, **func_kwargs)<br>
449<br>
450       # invariant: <code class="notranslate">func_outputs</code> contains only Tensors, IndexedSlices,</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/parallel_for/control_flow_ops.py in f()<br>
146   """<br>
147   def f():<br>
--&gt; 148     return _pfor_impl(loop_fn, iters, parallel_iterations=parallel_iterations)<br>
149   if context.executing_eagerly():<br>
150     f = function.defun(f)</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/parallel_for/control_flow_ops.py in _pfor_impl(loop_fn, iters, parallel_iterations)<br>
157   with ops.name_scope("loop_body"):<br>
158     loop_var = array_ops.placeholder(dtypes.int32, shape=[])<br>
--&gt; 159     loop_fn_outputs = loop_fn(loop_var)<br>
160   new_ops = set(ops.get_default_graph().get_operations()) - existing_ops<br>
161   iters = ops.convert_to_tensor(iters)</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/eager/backprop.py in loop_fn(i)<br>
1011       self._pop_tape()<br>
1012       return self.gradient(y, flat_sources,<br>
-&gt; 1013                            unconnected_gradients=unconnected_gradients)<br>
1014<br>
1015     try:</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/eager/backprop.py in gradient(self, target, sources, output_gradients, unconnected_gradients)<br>
944         flat_sources,<br>
945         output_gradients=output_gradients,<br>
--&gt; 946         unconnected_gradients=unconnected_gradients)<br>
947<br>
948     if not self._persistent:</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/eager/imperative_grad.py in imperative_grad(tape, target, sources, output_gradients, unconnected_gradients)<br>
70       sources,<br>
71       output_gradients,<br>
---&gt; 72       compat.as_str(unconnected_gradients.value))</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/eager/backprop.py in _gradient_function(op_name, attr_tuple, num_inputs, inputs, outputs, out_grads)<br>
129     return [None] * num_inputs<br>
130<br>
--&gt; 131   return grad_fn(mock_op, *out_grads)<br>
132<br>
133</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/array_grad.py in _ConcatGradV2(op, grad)<br>
220 def _ConcatGradV2(op, grad):<br>
221   return _ConcatGradHelper(<br>
--&gt; 222       op, grad, start_value_index=0, end_value_index=-1, dim_index=-1)<br>
223<br>
224</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/array_grad.py in _ConcatGradHelper(op, grad, start_value_index, end_value_index, dim_index)<br>
115       out_grads = array_ops.split(grad, sizes, non_neg_concat_dim)<br>
116     else:<br>
--&gt; 117       if constant_op.is_constant(concat_dim):<br>
118         # If concat_dim is a constant defined in a different context,<br>
119         # then we duplicate it in the current context to avoid passing it</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py in is_constant(tensor_or_op)<br>
293 def is_constant(tensor_or_op):<br>
294   if isinstance(tensor_or_op, ops.Tensor):<br>
--&gt; 295     op = tensor_or_op.op<br>
296   else:<br>
297     op = tensor_or_op</p>
<p dir="auto">/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in op(self)<br>
925   def op(self):<br>
926     raise AttributeError(<br>
--&gt; 927         "Tensor.op is meaningless when eager execution is enabled.")<br>
928<br>
929   <a class="user-mention notranslate" data-hovercard-type="organization" data-hovercard-url="/orgs/Property/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/Property">@Property</a></p>
<p dir="auto">AttributeError: Tensor.op is meaningless when eager execution is enabled.</p>