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

Function cast

python/tvm/topi/math.py:742–766  ·  view source on GitHub ↗

Cast input to specified data type. Parameters ---------- x : tvm.te.Tensor or Expr Input argument. dtype : str Data type. span : Optional[Span] The location of the cast in the source. Returns ------- y : tvm.te.Tensor The result.

(x, dtype, span=None)

Source from the content-addressed store, hash-verified

740
741
742def cast(x, dtype, span=None):
743 """Cast input to specified data type.
744
745 Parameters
746 ----------
747 x : tvm.te.Tensor or Expr
748 Input argument.
749
750 dtype : str
751 Data type.
752
753 span : Optional[Span]
754 The location of the cast in the source.
755
756 Returns
757 -------
758 y : tvm.te.Tensor
759 The result.
760 """
761 if isinstance(x, te.tensor.Tensor):
762 return te.compute(x.shape, lambda *i: x(*i).astype(dtype), tag=tag.ELEMWISE)
763 # pylint: disable=import-outside-toplevel
764 from tvm.tirx import _ffi_api
765
766 return _ffi_api._cast(dtype, x, span)
767
768
769def reinterpret(x, dtype):

Callers 15

maybe_castFunction · 0.70
gen_irFunction · 0.70
fast_expFunction · 0.70
fast_tanhFunction · 0.70
ceil_log2Function · 0.70
binary_searchFunction · 0.70
scatter_elementsFunction · 0.70
affine_gridFunction · 0.50
exclusive_scan_irFunction · 0.50
irFunction · 0.50
inclusive_scanFunction · 0.50
get_merge_beginFunction · 0.50

Calls 1

astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…