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

Function assert_fields

tests/python/relax/test_ast_printer.py:61–71  ·  view source on GitHub ↗

Given a target string, ensure that the string defines the specified node and that the given mappings of fields to values are present in the string. Strips all whitespace in the target and fields. Does not assume any particular ordering for the fields.

(nodename: str, fields: dict[str, str], target: str)

Source from the content-addressed store, hash-verified

59
60
61def assert_fields(nodename: str, fields: dict[str, str], target: str) -> None:
62 """
63 Given a target string, ensure that the string defines the specified node
64 and that the given mappings of fields to values are present in the string.
65 Strips all whitespace in the target and fields.
66 Does not assume any particular ordering for the fields.
67 """
68 stripped_target = strip_whitespace(target)
69 assert stripped_target.startswith(f"{nodename}(")
70 for field, value in fields.items():
71 assert f"{field}={strip_whitespace(value)}" in stripped_target
72
73
74# test cases are mostly adapted from text_expr, only testing very basic properties

Callers 5

test_typesFunction · 0.85
test_call_packedFunction · 0.85
test_op_attrsFunction · 0.85
test_call_tirFunction · 0.85
test_call_dps_packedFunction · 0.85

Calls 2

strip_whitespaceFunction · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…