MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / pure_match

Function pure_match

python/oneflow/test/gen_ops_process.py:157–184  ·  view source on GitHub ↗

Check whether x contains y. The purpose of identifying "." is to accurately match operator documents. For example, if we make pos = x.find(y) while y = clip_, either oneflow.Tensor.clip or oneflow.Tensor.clip_ is right. Besides, identifying "_" is important. For example, if we

(x, y)

Source from the content-addressed store, hash-verified

155
156
157def pure_match(x, y):
158 """
159 Check whether x contains y.
160
161 The purpose of identifying "." is to accurately match operator documents.
162 For example, if we make pos = x.find(y) while y = clip_, either oneflow.Tensor.clip or oneflow.Tensor.clip_ is right.
163
164 Besides, identifying "_" is important.
165 For example, if we make pos = x.find(y) while y = squeeze, either test of squeeze or unsqueeze is right.
166 """
167 x = x.lower()
168 y = y.lower()
169 pos = -1
170 if "." in x:
171 x = x.split(".")
172 for i in x:
173 if i == y:
174 pos = 1
175 break
176 elif "_" in y:
177 pos = x.find(y)
178 else:
179 x = x.split("_")
180 for i in x:
181 if i == y:
182 pos = 1
183 break
184 return pos != -1
185
186
187def match_test_func(func, func_list):

Callers 1

match_test_funcFunction · 0.85

Calls 3

splitMethod · 0.80
findMethod · 0.80
lowerMethod · 0.45

Tested by

no test coverage detected