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")
| 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( |