| 207 | } |
| 208 | |
| 209 | core::TensorValue replicate_pad1d( |
| 210 | core::ModuleBuildContext & ctx, |
| 211 | const core::TensorValue & input, |
| 212 | int64_t left, |
| 213 | int64_t right) { |
| 214 | if (left < 0 || right < 0) { |
| 215 | throw std::runtime_error("FlashSR replicate padding must be non-negative"); |
| 216 | } |
| 217 | auto output = input; |
| 218 | constexpr int axis = 2; |
| 219 | if (left > 0) { |
| 220 | auto edge = modules::SliceModule({axis, 0, 1}).build(ctx, input); |
| 221 | auto pad_shape = edge.shape; |
| 222 | pad_shape.dims[axis] = left; |
| 223 | auto pad = modules::RepeatModule({pad_shape}).build(ctx, edge); |
| 224 | output = modules::ConcatModule({axis}).build(ctx, pad, output); |
| 225 | } |
| 226 | if (right > 0) { |
| 227 | auto edge = modules::SliceModule({axis, input.shape.dims[axis] - 1, 1}).build(ctx, input); |
| 228 | auto pad_shape = edge.shape; |
| 229 | pad_shape.dims[axis] = right; |
| 230 | auto pad = modules::RepeatModule({pad_shape}).build(ctx, edge); |
| 231 | output = modules::ConcatModule({axis}).build(ctx, output, pad); |
| 232 | } |
| 233 | return output; |
| 234 | } |
| 235 | |
| 236 | core::TensorValue activation1d( |
| 237 | core::ModuleBuildContext & ctx, |
no test coverage detected