| 1341 | } |
| 1342 | |
| 1343 | void CLQLSTMLayer::prepare() |
| 1344 | { |
| 1345 | if (!_is_prepared) |
| 1346 | { |
| 1347 | // Pre-transpose weights to be used in GEMM. |
| 1348 | _input_to_forget_weights_transposed.allocator()->allocate(); |
| 1349 | _input_to_cell_weights_transposed.allocator()->allocate(); |
| 1350 | _input_to_output_weights_transposed.allocator()->allocate(); |
| 1351 | _recurrent_to_forget_weights_transposed.allocator()->allocate(); |
| 1352 | _recurrent_to_cell_weights_transposed.allocator()->allocate(); |
| 1353 | _recurrent_to_output_weights_transposed.allocator()->allocate(); |
| 1354 | _transpose_input_to_forget_weights.run(); |
| 1355 | _transpose_input_to_cell_weights.run(); |
| 1356 | _transpose_input_to_output_weights.run(); |
| 1357 | _transpose_recurrent_to_forget_weights.run(); |
| 1358 | _transpose_recurrent_to_cell_weights.run(); |
| 1359 | _transpose_recurrent_to_output_weights.run(); |
| 1360 | |
| 1361 | // Precompute effective biases |
| 1362 | if (_has_cifg) |
| 1363 | { |
| 1364 | _ones.map(true); |
| 1365 | std::fill_n(reinterpret_cast<int16_t *>(_ones.buffer()), |
| 1366 | _ones.info()->total_size() / _ones.info()->element_size(), 32767); |
| 1367 | _ones.unmap(); |
| 1368 | } |
| 1369 | else |
| 1370 | { |
| 1371 | _input_to_input_eff_bias.allocator()->allocate(); |
| 1372 | _recurrent_to_input_eff_bias.allocator()->allocate(); |
| 1373 | |
| 1374 | ITensorPack input_to_input_red_pack = {{ACL_SRC, _input_to_input_weights}, |
| 1375 | {ACL_DST, &_input_to_input_eff_bias}}; |
| 1376 | CLScheduler::get().enqueue_op(*_input_to_input_reduction, input_to_input_red_pack, false); |
| 1377 | |
| 1378 | ITensorPack rec_to_input_red_pack = {{ACL_SRC, _recurrent_to_input_weights}, |
| 1379 | {ACL_DST, &_recurrent_to_input_eff_bias}}; |
| 1380 | CLScheduler::get().enqueue_op(*_recurrent_to_input_reduction, rec_to_input_red_pack, false); |
| 1381 | |
| 1382 | _input_to_input_weights_transposed.allocator()->allocate(); |
| 1383 | _recurrent_to_input_weights_transposed.allocator()->allocate(); |
| 1384 | _transpose_input_to_input_weights.run(); |
| 1385 | _transpose_recurrent_to_input_weights.run(); |
| 1386 | _input_to_input_weights->mark_as_unused(); |
| 1387 | _recurrent_to_input_weights->mark_as_unused(); |
| 1388 | } |
| 1389 | _input_to_forget_eff_bias.allocator()->allocate(); |
| 1390 | _recurrent_to_forget_eff_bias.allocator()->allocate(); |
| 1391 | _input_to_cell_eff_bias.allocator()->allocate(); |
| 1392 | _recurrent_to_cell_eff_bias.allocator()->allocate(); |
| 1393 | _input_to_output_eff_bias.allocator()->allocate(); |
| 1394 | _recurrent_to_output_eff_bias.allocator()->allocate(); |
| 1395 | |
| 1396 | ITensorPack input_to_forget_red_pack = {{ACL_SRC, _input_to_forget_weights}, |
| 1397 | {ACL_DST, &_input_to_forget_eff_bias}}; |
| 1398 | CLScheduler::get().enqueue_op(*_input_to_forget_reduction, input_to_forget_red_pack, false); |
| 1399 | |
| 1400 | ITensorPack rec_to_forget_red_pack = {{ACL_SRC, _recurrent_to_forget_weights}, |
nothing calls this directly
no test coverage detected