def testOtherDtypesNotConverted(self): int32_tensor = tf.ones([2, 3], dtype=tf.int32) converted_tensor = utils.bfloat16_to_float32(int32_tensor) self.assertEqual(converted_tensor.dtype, tf.int32)
def testBfloat16ToFloat32(self): bfloat16_tensor = tf.random.uniform([2, 3], dtype=tf.bfloat16) float32_tensor = utils.bfloat16_to_float32(bfloat16_tensor) self.assertEqual(float32_tensor.dtype, tf.float32)