CTCLossV2 Op Not Supported on MacOS M1

System Information

  • MacOS version: 13.4

  • TensorFlow (macos) version: tf-nightly==2.14.0.dev20230616

  • TensorFlow-Metal Plugin Version: 1.0.1

Problem Description

I'm trying to compute the CTC Loss using TensorFlow's tf.nn.ctc_loss on M1 Mac, but an error is thrown indicating that no OpKernel was registered to support the CTCLossV2 operation. However, when using the CPU or even tf.keras.backend.ctc_batch_cost, it works fine. The error stack trace is as follows:

    tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.InvalidArgumentError: Graph execution error:

Detected at node CTCLossV2 defined at (most recent call last):
<stack traces unavailable>
No OpKernel was registered to support Op 'CTCLossV2' used by {{node CTCLossV2}} with these attrs: [ctc_merge_repeated=true, preprocess_collapse_repeated=false, ignore_longer_outputs_than_inputs=false]
Registered devices: [CPU, GPU]
Registered kernels:
  <no registered kernels>

         [[CTCLossV2]]
         [[ctc_loss_func/PartitionedCall]] [Op:__inference_train_function_13095]
Answered by Frameworks Engineer in 757143022

Hi @arthurflor23

Thanks for reporting this. This looks like a missing op registration on tensorflow-metal side so I'll add it to our work list to be implemented.

Accepted Answer

Hi @arthurflor23

Thanks for reporting this. This looks like a missing op registration on tensorflow-metal side so I'll add it to our work list to be implemented.

Any updates on this?

Hello I was trying tf.nn.ctc_loss using the example on the tensorflow documentation page https://www.tensorflow.org/api_docs/python/tf/nn/ctc_loss. With tensorflow metal 1.1.0. the results contains Nan for all but the blank label. The result is

<tf.Tensor: shape=(12, 8, 6), dtype=float32, numpy=
array([[[-0.4672395 ,         nan,         nan,         nan,
                 nan,         nan],
        [-0.5027784 ,         nan,         nan,         nan,
                 nan,         nan],
        [-0.56907517,         nan,         nan,         nan,
                 nan,         nan],...

The same code works well when runing on the CPU without the metal plugin.

CTCLossV2 Op Not Supported on MacOS M1
 
 
Q