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

Function forward

tests/python/relax/test_op_gradient_numeric.py:142–159  ·  view source on GitHub ↗
(*inputs)

Source from the content-addressed store, hash-verified

140
141 # The inputs of the forward function are inputs_filtered below.
142 def forward(*inputs):
143 inputs_iter = iter(inputs)
144 inputs_tvm = [
145 _numpy_to_tvm(next(inputs_iter))
146 if i not in ignore_grads
147 else _numpy_to_tvm(inputs_numpy[i])
148 for i in range(len(inputs_numpy))
149 ]
150 result = forward_vm[func_name](*inputs_tvm)
151 result_numpy = _tvm_to_numpy(result)
152 if isinstance(result_numpy, list):
153 assert isinstance(weights, list)
154 assert len(weights) == len(result_numpy)
155 ret = 0
156 for i, weight in enumerate(weights):
157 ret += np.sum(weight * result_numpy[i])
158 return ret
159 return np.sum(weights * result_numpy)
160
161 # The gradient function
162 assert isinstance(call.op, Op)

Callers

nothing calls this directly

Calls 3

_numpy_to_tvmFunction · 0.70
_tvm_to_numpyFunction · 0.70
sumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…