(inp, rep, axis)
| 1138 | |
| 1139 | |
| 1140 | def _tile_one_dim(inp, rep, axis): |
| 1141 | shape = astensor1d(inp.shape, inp, dtype="int32", device=inp.device) |
| 1142 | # assume inp.ndim is not changed during trace |
| 1143 | max_axis = len(shape) - 1 |
| 1144 | |
| 1145 | base_shape, bcast_shape, target_shape = [], [], [] |
| 1146 | |
| 1147 | if axis != 0: |
| 1148 | base_shape.append(shape[:axis]) |
| 1149 | bcast_shape.append(shape[:axis]) |
| 1150 | target_shape.append(shape[:axis]) |
| 1151 | base_shape.extend([[1,], shape[axis:]]) |
| 1152 | bcast_shape.extend([rep, shape[axis:]]) |
| 1153 | target_shape.append(shape[axis] * rep) |
| 1154 | if axis + 1 <= max_axis: |
| 1155 | target_shape.append(shape[axis + 1 :]) |
| 1156 | |
| 1157 | base_shape = astensor1d(base_shape) |
| 1158 | bcast_shape = astensor1d(bcast_shape) |
| 1159 | target_shape = astensor1d(target_shape) |
| 1160 | out = broadcast_to(inp.reshape(base_shape), bcast_shape).reshape(target_shape) |
| 1161 | return out |
| 1162 | |
| 1163 | |
| 1164 | def tile(inp: Tensor, reps: Iterable[int]): |
no test coverage detected