| 51 | |
| 52 | template<typename T> |
| 53 | void Decoder<T>::allocateBuffer() |
| 54 | { |
| 55 | if (is_allocate_buffer_ == false) { |
| 56 | decoder_normed_input_ = reinterpret_cast<T*>( |
| 57 | allocator_->reMalloc(decoder_normed_input_, sizeof(T) * max_batch_size_ * hidden_units_, false)); |
| 58 | self_attn_output_ = reinterpret_cast<T*>( |
| 59 | allocator_->reMalloc(self_attn_output_, sizeof(T) * max_batch_size_ * hidden_units_, false)); |
| 60 | normed_self_attn_output_ = reinterpret_cast<T*>( |
| 61 | allocator_->reMalloc(normed_self_attn_output_, sizeof(T) * max_batch_size_ * hidden_units_, false)); |
| 62 | cross_attn_output_ = reinterpret_cast<T*>( |
| 63 | allocator_->reMalloc(cross_attn_output_, sizeof(T) * max_batch_size_ * hidden_units_, false)); |
| 64 | normed_cross_attn_output_ = reinterpret_cast<T*>( |
| 65 | allocator_->reMalloc(normed_cross_attn_output_, sizeof(T) * max_batch_size_ * hidden_units_, false)); |
| 66 | decoder_layer_output_ = reinterpret_cast<T*>( |
| 67 | allocator_->reMalloc(decoder_layer_output_, sizeof(T) * max_batch_size_ * hidden_units_, false)); |
| 68 | is_allocate_buffer_ = true; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | template<typename T> |
| 73 | void Decoder<T>::allocateBuffer(size_t batch_size) |