MCPcopy Index your code
hub / github.com/apache/tvm / _convert_pytorch_to_tvm

Method _convert_pytorch_to_tvm

python/tvm/relax/base_py_module.py:362–371  ·  view source on GitHub ↗

Convert PyTorch tensors to TVM Tensors using DLPack.

(
        self, tensors: Any | list[Any] | tuple[Any, ...]
    )

Source from the content-addressed store, hash-verified

360 return dtype_mapping.get(str(tvm_dtype), torch.float32)
361
362 def _convert_pytorch_to_tvm(
363 self, tensors: Any | list[Any] | tuple[Any, ...]
364 ) -> Tensor | list[Tensor]:
365 """Convert PyTorch tensors to TVM Tensors using DLPack."""
366 # pylint: disable=import-outside-toplevel
367 import torch
368
369 if isinstance(tensors, list | tuple):
370 return [self._convert_single_pytorch_to_tvm(t) for t in tensors]
371 return self._convert_single_pytorch_to_tvm(tensors)
372
373 def _convert_single_pytorch_to_tvm(self, tensor: Any) -> Tensor:
374 """Convert a single PyTorch tensor to TVM Tensor with faster DLPack converter."""

Callers 12

wrapperMethod · 0.95
call_tirMethod · 0.95
call_dps_packedMethod · 0.95
addMethod · 0.80
multiplyMethod · 0.80
ml_pipelineMethod · 0.80
data_preprocessingMethod · 0.80
vectorized_operationMethod · 0.80
sklearn_integrationMethod · 0.80
forwardMethod · 0.80
forwardMethod · 0.80
forwardMethod · 0.80

Calls 1

Tested by 6

addMethod · 0.64
multiplyMethod · 0.64
ml_pipelineMethod · 0.64
data_preprocessingMethod · 0.64
vectorized_operationMethod · 0.64
sklearn_integrationMethod · 0.64