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

Method pushArgToStack

jvm/core/src/main/java/org/apache/tvm/Function.java:206–248  ·  view source on GitHub ↗
(Object arg)

Source from the content-addressed store, hash-verified

204 }
205
206 private static void pushArgToStack(Object arg) {
207 if (arg instanceof TensorBase) {
208 TensorBase nd = (TensorBase) arg;
209 if (nd instanceof Tensor) {
210 Base._LIB.tvmFFIFunctionPushArgHandle(((Tensor) nd).handle, TypeIndex.kTVMFFITensor);
211 } else {
212 Base._LIB.tvmFFIFunctionPushArgHandle(nd.dltensorHandle, TypeIndex.kTVMFFIDLTensorPtr);
213 }
214 } else if (arg instanceof TVMObject) {
215 TVMObject obj = (TVMObject) arg;
216 Base._LIB.tvmFFIFunctionPushArgHandle(obj.handle, obj.typeIndex);
217 } else if (arg instanceof Integer) {
218 Base._LIB.tvmFFIFunctionPushArgLong((Integer) arg);
219 } else if (arg instanceof Long) {
220 Base._LIB.tvmFFIFunctionPushArgLong((Long) arg);
221 } else if (arg instanceof Float) {
222 Base._LIB.tvmFFIFunctionPushArgDouble((Float) arg);
223 } else if (arg instanceof Double) {
224 Base._LIB.tvmFFIFunctionPushArgDouble((Double) arg);
225 } else if (arg instanceof String) {
226 Base._LIB.tvmFFIFunctionPushArgString((String) arg);
227 } else if (arg instanceof byte[]) {
228 Base._LIB.tvmFFIFunctionPushArgBytes((byte[]) arg);
229 } else if (arg instanceof Device) {
230 Base._LIB.tvmFFIFunctionPushArgDevice((Device) arg);
231 } else if (arg instanceof TVMValueBytes) {
232 byte[] bytes = ((TVMValueBytes) arg).value;
233 Base._LIB.tvmFFIFunctionPushArgBytes(bytes);
234 } else if (arg instanceof TVMValueString) {
235 String str = ((TVMValueString) arg).value;
236 Base._LIB.tvmFFIFunctionPushArgString(str);
237 } else if (arg instanceof TVMValueDouble) {
238 double value = ((TVMValueDouble) arg).value;
239 Base._LIB.tvmFFIFunctionPushArgDouble(value);
240 } else if (arg instanceof TVMValueLong) {
241 long value = ((TVMValueLong) arg).value;
242 Base._LIB.tvmFFIFunctionPushArgLong(value);
243 } else if (arg instanceof TVMValueNull) {
244 Base._LIB.tvmFFIFunctionPushArgHandle(0, TypeIndex.kTVMFFINone);
245 } else {
246 throw new IllegalArgumentException("Invalid argument: " + arg);
247 }
248 }
249
250 public static interface Callback {
251 public Object invoke(TVMValue... args);

Callers 1

callMethod · 0.95

Tested by

no test coverage detected