Assert lhs and rhs are structurally equal to each other. Parameters ---------- lhs : Object The left operand. rhs : Object The left operand. map_free_vars : bool Whether or not shall we map free vars that does not bound to any definitions as equ
(lhs, rhs, map_free_vars=False)
| 163 | |
| 164 | |
| 165 | def assert_structural_equal(lhs, rhs, map_free_vars=False): |
| 166 | """Assert lhs and rhs are structurally equal to each other. |
| 167 | |
| 168 | Parameters |
| 169 | ---------- |
| 170 | lhs : Object |
| 171 | The left operand. |
| 172 | |
| 173 | rhs : Object |
| 174 | The left operand. |
| 175 | |
| 176 | map_free_vars : bool |
| 177 | Whether or not shall we map free vars that does |
| 178 | not bound to any definitions as equal to each other. |
| 179 | |
| 180 | Raises |
| 181 | ------ |
| 182 | ValueError : if assertion does not hold. |
| 183 | |
| 184 | See Also |
| 185 | -------- |
| 186 | tvm_ffi.structural_equal |
| 187 | """ |
| 188 | first_mismatch = tvm_ffi.get_first_structural_mismatch(lhs, rhs, map_free_vars) |
| 189 | if first_mismatch is not None: |
| 190 | from tvm.runtime.script_printer import ( # pylint: disable=import-outside-toplevel |
| 191 | PrinterConfig, |
| 192 | _script, |
| 193 | ) |
| 194 | |
| 195 | lhs_path, rhs_path = first_mismatch |
| 196 | lhs_script = _script(lhs, PrinterConfig(syntax_sugar=False, path_to_underline=[lhs_path])) |
| 197 | rhs_script = _script(rhs, PrinterConfig(syntax_sugar=False, path_to_underline=[rhs_path])) |
| 198 | raise ValueError( |
| 199 | f"StructuralEqual check failed, caused by lhs at {lhs_path}:\n" |
| 200 | f"{lhs_script}\n" |
| 201 | f"and rhs at {rhs_path}:\n" |
| 202 | f"{rhs_script}" |
| 203 | ) |
| 204 | |
| 205 | |
| 206 | def deprecated( |
searching dependent graphs…