[llvm] 3546b5c - [mlgo] Fix flaky test

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 21:30:47 PDT 2022


Author: Mircea Trofin
Date: 2022-08-26T21:29:25-07:00
New Revision: 3546b5c5207928be2ae2e3a86cf95b9ad024bd69

URL: https://github.com/llvm/llvm-project/commit/3546b5c5207928be2ae2e3a86cf95b9ad024bd69
DIFF: https://github.com/llvm/llvm-project/commit/3546b5c5207928be2ae2e3a86cf95b9ad024bd69.diff

LOG: [mlgo] Fix flaky test

The source of the flakyness is internal uninitialized buffers due to
a dangling variable in the model.

Added: 
    

Modified: 
    llvm/lib/Analysis/models/gen-inline-oz-test-model.py

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/models/gen-inline-oz-test-model.py b/llvm/lib/Analysis/models/gen-inline-oz-test-model.py
index 4408a9eb97bd2..d8737f26e0d88 100644
--- a/llvm/lib/Analysis/models/gen-inline-oz-test-model.py
+++ b/llvm/lib/Analysis/models/gen-inline-oz-test-model.py
@@ -102,14 +102,8 @@ def get_output_spec_path(path):
 def build_mock_model(path, signature):
   """Build and save the mock model with the given signature"""
   module = tf.Module()
-
-  # We have to set this useless variable in order for the TF C API to correctly
-  # intake it
-  module.var = tf.Variable(0.)
-
   def action(*inputs):
-    s = tf.reduce_sum([tf.cast(x, tf.float32) for x in tf.nest.flatten(inputs)])
-    return {signature['output']: tf.cast(tf.divide((s + module.var), tf.abs(s + module.var)), tf.int64)}
+    return {signature['output']: tf.constant(value=1, dtype=tf.int64)}
 
   module.action = tf.function()(action)
   action = {'action': module.action.get_concrete_function(signature['inputs'])}


        


More information about the llvm-commits mailing list