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

Function const_vector

python/tvm/topi/utils.py:211–240  ·  view source on GitHub ↗

convert a const numpy 1-dimensional vector to tvm tensor Parameters ---------- vector: numpy.ndarray Const input array name: str, optional The name of output op Returns ------- tensor: Tensor The created tensor

(vector, name="const_vector")

Source from the content-addressed store, hash-verified

209
210
211def const_vector(vector, name="const_vector"):
212 """convert a const numpy 1-dimensional vector to tvm tensor
213
214 Parameters
215 ----------
216 vector: numpy.ndarray
217 Const input array
218 name: str, optional
219 The name of output op
220
221 Returns
222 -------
223 tensor: Tensor
224 The created tensor
225 """
226 if not isinstance(vector, np.ndarray):
227 vector = np.array(vector)
228 row = vector.shape[0]
229 dtype = str(vector.dtype)
230 idxm = tvm.tirx.indexmod
231
232 def select_array(i):
233 now = tvm.tirx.const(0.0, dtype)
234 for ii in range(row):
235 now = tvm.tirx.Select(
236 tvm.tirx.all(idxm(i, row) == ii), tvm.tirx.const(vector[ii], dtype), now
237 )
238 return now
239
240 return te.compute(vector.shape, select_array, name=name)
241
242
243def get_float_tuple(in_tuple):

Callers 2

strided_sliceFunction · 0.85
dynamic_strided_sliceFunction · 0.85

Calls 1

strFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…