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

Function get_const_tuple

python/tvm/topi/utils.py:176–208  ·  view source on GitHub ↗

Verifies input tuple is IntImm or Var, returns tuple of int or Var. Parameters ---------- in_tuple : tuple of Expr The input. Returns ------- out_tuple : tuple of int The output.

(in_tuple)

Source from the content-addressed store, hash-verified

174
175
176def get_const_tuple(in_tuple):
177 """Verifies input tuple is IntImm or Var, returns tuple of int or Var.
178
179 Parameters
180 ----------
181 in_tuple : tuple of Expr
182 The input.
183
184 Returns
185 -------
186 out_tuple : tuple of int
187 The output.
188 """
189 if isinstance(in_tuple, te.tensor.Tensor):
190 raise TypeError(
191 "get_const_tuple expects a tuple-like shape (e.g., tensor.shape), "
192 "but got a te.Tensor. Did you mean get_const_tuple(tensor.shape)?"
193 )
194 ret = []
195 ana = None
196 for elem in in_tuple:
197 if isinstance(elem, tvm.tirx.Var):
198 ret.append(elem)
199 elif not isinstance(elem, tvm.tirx.IntImm | int):
200 ana = tvm.arith.Analyzer() if ana is None else ana
201 elem = ana.simplify(elem)
202 if not isinstance(elem, tvm.tirx.IntImm):
203 ret.append(elem)
204 else:
205 ret.append(get_const_int(elem))
206 else:
207 ret.append(get_const_int(elem))
208 return tuple(ret)
209
210
211def const_vector(vector, name="const_vector"):

Callers 15

handle_attentionMethod · 0.90
_impl_v17Method · 0.90
bitserial_denseFunction · 0.90
test_bilayout_shapeFunction · 0.90
test_bilayout_indexFunction · 0.90
get_shapeFunction · 0.85
_computeFunction · 0.85
topkFunction · 0.85
_get_workloadFunction · 0.85
deformable_conv2d_nchwFunction · 0.85
deformable_conv2d_nhwcFunction · 0.85

Calls 4

get_const_intFunction · 0.85
tupleFunction · 0.85
simplifyMethod · 0.80
appendMethod · 0.45

Tested by 2

test_bilayout_shapeFunction · 0.72
test_bilayout_indexFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…