Skip to content

Lack of support for half precision type in linear algebra operators #22086

@ajonkisz

Description

@ajonkisz

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): CentOS 7
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
  • TensorFlow installed from (source or binary): Binary
  • TensorFlow version (use command below): v1.9.0-0-g25c197e023 1.9.0
  • Python version: Python 3.6.5
  • Bazel version (if compiling from source): N/A
  • GCC/Compiler version (if compiling from source): N/A
  • CUDA/cuDNN version: 9.0
  • GPU model and memory: Tesla V-100 16160MiB
  • Exact command to reproduce:
    Minimal example to reproduce the issue
import tensorflow as tf
from tensorflow.python.ops import gen_linalg_ops

a = tf.placeholder(tf.float16, shape=[2, 2])
gen_linalg_ops.qr(a)

Problem

There seems to be no support for float16 type in linalg_ops.cc at all. Is there any reason as to why that is the case? Or a way around it?

I have run into this issue when trying to use keras with float16 (by editing .keras/keras.json), sequential model with GRU cells. Code included for completeness:

import tensorflow.keras as keras

model = keras.Sequential()
model.add(keras.layers.GRU(128, recurrent_dropout=0.75, input_shape=(200, 4)))

Log

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../python3.6/site-packages/tensorflow/python/ops/gen_linalg_ops.py", line 1494, in qr
    "Qr", input=input, full_matrices=full_matrices, name=name)
  File ".../python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 609, in _apply_op_helper
    param_name=input_name)
  File ".../python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 60, in _SatisfiesTypeConstraint
    ", ".join(dtypes.as_dtype(x).name for x in allowed_list)))
TypeError: Value passed to parameter 'input' has DataType float16 not in list of allowed values: float64, float32, complex64, complex128

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions