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

Function get_const_int

python/tvm/topi/utils.py:107–127  ·  view source on GitHub ↗

Verifies expr is integer and get the constant value. Parameters ---------- expr : tvm.Expr or int The input expression. Returns ------- out_value : int The output.

(expr)

Source from the content-addressed store, hash-verified

105
106
107def get_const_int(expr):
108 """Verifies expr is integer and get the constant value.
109
110 Parameters
111 ----------
112 expr : tvm.Expr or int
113 The input expression.
114
115 Returns
116 -------
117 out_value : int
118 The output.
119 """
120 if isinstance(expr, Integral):
121 return expr
122 if not isinstance(expr, tvm.tirx.IntImm):
123 ana = tvm.arith.Analyzer()
124 expr = ana.simplify(expr)
125 if not isinstance(expr, tvm.tirx.IntImm):
126 raise ValueError("Expect value to be constant int")
127 return int(expr.value)
128
129
130def get_const_float(expr):

Callers 10

get_const_tupleFunction · 0.85
scanopFunction · 0.85
preluFunction · 0.85
binarize_packFunction · 0.85
infer_padFunction · 0.85
infer_pad3dFunction · 0.85
infer_strideFunction · 0.85
bitpackFunction · 0.85
_get_workloadFunction · 0.85

Calls 1

simplifyMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…