MCPcopy Create free account
hub / github.com/apache/tvm / verify_callop_float_only

Function verify_callop_float_only

tests/python/tirx-base/test_tir_ops.py:146–173  ·  view source on GitHub ↗
(f)

Source from the content-addressed store, hash-verified

144 raise ValueError("Unknown binary op format!")
145
146 def verify_callop_float_only(f):
147 for lhs_dtype in ["int32", "float32", "float64"]:
148 for rhs_dtype in ["int32", "float32", "float64"]:
149 lhs = tvm.tirx.Var("lhs", lhs_dtype)
150 rhs = tvm.tirx.Var("rhs", rhs_dtype)
151 if "float" not in lhs_dtype and "float" not in rhs_dtype:
152 check_throws(lambda: f(lhs, rhs))
153 elif "float" in lhs_dtype:
154 out = f(lhs, rhs)
155
156 # Upcasting for floating point types
157 dtypes = [lhs_dtype, rhs_dtype]
158 if "float64" in dtypes:
159 target_dtype = "float64"
160 elif "float32" in dtypes:
161 target_dtype = "float32"
162 else:
163 target_dtype = "int32"
164 assert out.dtype == target_dtype
165
166 # Final inputs are the right type
167 assert out.args[0].dtype == target_dtype
168 assert out.args[1].dtype == target_dtype
169 else:
170 out = f(lhs, rhs)
171 assert out.dtype == rhs_dtype
172 assert out.args[0].dtype == rhs_dtype
173 assert out.args[1].dtype == rhs_dtype
174
175 verify_general_dtype_support(lambda a, b: a + b)
176 verify_general_dtype_support(lambda a, b: a * b)

Callers 1

test_binary_dtype_matchFunction · 0.85

Calls 2

check_throwsFunction · 0.85
fFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…