| 216 | merged.reserve((steps.size() + 1) / 2); |
| 217 | for (size_t i = 0; i < steps.size(); i += 2) { |
| 218 | merged.push_back(i + 1 < steps.size() ? concat_rows.build(ctx, steps[i], steps[i + 1]) : steps[i]); |
| 219 | } |
| 220 | steps = std::move(merged); |
| 221 | } |
| 222 | return {steps.front(), hidden, cell}; |
| 223 | } |
| 224 | |
| 225 | auto sequence = steps[0]; |
| 226 | for (int64_t t = 1; t < frames; ++t) { |
| 227 | sequence = concat_rows.build(ctx, sequence, steps[static_cast<size_t>(t)]); |
| 228 | } |
| 229 | return LSTMSequenceOutputs{sequence, hidden, cell}; |
| 230 | } |
| 231 | |
| 232 | } // namespace |
| 233 | |
| 234 | LSTMCellModule::LSTMCellModule(LSTMCellConfig config) : config_(config) { |
| 235 | if (config_.input_size <= 0 || config_.hidden_size <= 0) { |
| 236 | throw std::runtime_error("LSTMCellConfig dimensions must be positive"); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | const LSTMCellConfig & LSTMCellModule::config() const noexcept { |
| 241 | return config_; |
| 242 | } |
no test coverage detected