| 20 | |
| 21 | template<typename T> |
| 22 | void BartDecoder<T>::initialize() |
| 23 | { |
| 24 | self_attention_layer_ = |
| 25 | new TensorParallelDecoderSelfAttentionLayer<T>(max_batch_size_, |
| 26 | head_num_, |
| 27 | size_per_head_, |
| 28 | d_model_, |
| 29 | q_scaling_, // adjust according to checkpoint structure |
| 30 | tensor_para_, |
| 31 | stream_, |
| 32 | cublas_wrapper_, |
| 33 | allocator_, |
| 34 | true, |
| 35 | is_free_buffer_after_forward_, |
| 36 | false, |
| 37 | 0, |
| 38 | custom_all_reduce_comm_, |
| 39 | enable_custom_all_reduce_); |
| 40 | // (1.0f/ sqrtf((float)size_per_head_)) |
| 41 | cross_attention_layer_ = |
| 42 | new TensorParallelDecoderCrossAttentionLayer<T>(max_batch_size_, |
| 43 | head_num_, |
| 44 | size_per_head_, |
| 45 | d_model_, |
| 46 | q_scaling_, // adjust according to checkpoint structure |
| 47 | tensor_para_, |
| 48 | stream_, |
| 49 | cublas_wrapper_, |
| 50 | allocator_, |
| 51 | is_free_buffer_after_forward_, |
| 52 | custom_all_reduce_comm_, |
| 53 | enable_custom_all_reduce_); |
| 54 | |
| 55 | bool use_gated_activation = activation_type_ == ActivationType::GeGLU || activation_type_ == ActivationType::ReGLU |
| 56 | || activation_type_ == ActivationType::SiGLU; |
| 57 | if (activation_type_ == ActivationType::Gelu || activation_type_ == ActivationType::GeGLU) { |
| 58 | ffn_layer_ = new TensorParallelGeluFfnLayer<T>(max_batch_size_, |
| 59 | 1, |
| 60 | 1, |
| 61 | d_model_, |
| 62 | 0, |
| 63 | inter_size_, |
| 64 | tensor_para_, |
| 65 | stream_, |
| 66 | cublas_wrapper_, |
| 67 | allocator_, |
| 68 | true, |
| 69 | is_free_buffer_after_forward_, |
| 70 | false, |
| 71 | 0, |
| 72 | use_gated_activation, |
| 73 | custom_all_reduce_comm_, |
| 74 | enable_custom_all_reduce_); |
| 75 | } |
| 76 | else if (activation_type_ == ActivationType::Relu || activation_type_ == ActivationType::ReGLU) { |
| 77 | ffn_layer_ = new TensorParallelReluFfnLayer<T>(max_batch_size_, |
| 78 | 1, |
| 79 | 1, |
nothing calls this directly
no outgoing calls
no test coverage detected