Skip to content

Commit 4cd7215

Browse files
dusenberrymwedward-bot
authored andcommitted
Fixes an edge case in which the input dtype is not equal to the compute dtype.
The underlying `tf.keras.layers.Dense` layer has the same conditional statement. PiperOrigin-RevId: 500249123
1 parent 857f32c commit 4cd7215

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

edward2/tensorflow/layers/dense.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ def build(self, input_shape):
549549
self.built = True
550550

551551
def call(self, inputs):
552+
if inputs.dtype != self.compute_dtype:
553+
inputs = tf.cast(inputs, dtype=self.compute_dtype)
554+
552555
batch_size = tf.shape(inputs)[0]
553556
input_dim = self.alpha.shape[-1]
554557
examples_per_model = batch_size // self.ensemble_size

0 commit comments

Comments
 (0)