MCPcopy
hub / github.com/apache/tvm / from_struct_info

Method from_struct_info

python/tvm/relax/frontend/nn/core.py:125–150  ·  view source on GitHub ↗

Construct a nn.Tensor from a Relax TensorStructInfo. TensorStructInfo is the Relax type-level description of a tensor, carrying its shape and dtype without holding actual data. This factory creates an unbound placeholder ``nn.Tensor`` that can be used as a symbolic input whe

(struct_info: rx.TensorStructInfo, name: str = "tensor")

Source from the content-addressed store, hash-verified

123
124 @staticmethod
125 def from_struct_info(struct_info: rx.TensorStructInfo, name: str = "tensor") -> "Tensor":
126 """Construct a nn.Tensor from a Relax TensorStructInfo.
127
128 TensorStructInfo is the Relax type-level description of a tensor, carrying its shape
129 and dtype without holding actual data. This factory creates an unbound placeholder
130 ``nn.Tensor`` that can be used as a symbolic input when tracing an ``nn.Module``.
131
132 Parameters
133 ----------
134 struct_info : rx.TensorStructInfo
135 The struct info describing the tensor's shape and dtype.
136
137 name : str
138 Name hint for the underlying Relax variable.
139
140 Returns
141 -------
142 tensor : Tensor
143 A symbolic ``nn.Tensor`` backed by a ``relax.Var`` with the given struct info.
144 """
145 return Tensor(
146 _expr=rx.Var(
147 name_hint=name,
148 struct_info=struct_info,
149 )
150 )
151
152 @staticmethod
153 def placeholder(

Callers

nothing calls this directly

Calls 1

TensorClass · 0.70

Tested by

no test coverage detected