| 51 | |
| 52 | template<typename T> |
| 53 | int wenetDecoderExample(size_t batch_size, size_t num_layers, size_t seq_len, size_t head_num, size_t size_per_head) |
| 54 | { |
| 55 | // printf("[INFO] Device: %s \n", getDeviceName().c_str()); |
| 56 | |
| 57 | const size_t hidden_units = head_num * size_per_head; |
| 58 | const size_t d_model = hidden_units; |
| 59 | |
| 60 | const size_t max_len = 5000; |
| 61 | const size_t inter_size = 2048; |
| 62 | const size_t vocab_size = 4233; |
| 63 | const size_t beam_width = 10; |
| 64 | const int sm = getSMVersion(); |
| 65 | const float q_scaling = 1.0f; |
| 66 | |
| 67 | const size_t seq_len1 = 63; |
| 68 | |
| 69 | cudaStream_t stream; |
| 70 | cublasHandle_t cublas_handle; |
| 71 | cublasLtHandle_t cublaslt_handle; |
| 72 | check_cuda_error(cudaStreamCreate(&stream)); |
| 73 | check_cuda_error(cublasCreate(&cublas_handle)); |
| 74 | check_cuda_error(cublasLtCreate(&cublaslt_handle)); |
| 75 | #ifdef SPARSITY_ENABLED |
| 76 | cusparseLtHandle_t cusparselt_handle; |
| 77 | CHECK_CUSPARSE(cusparseLtInit(&cusparselt_handle)); |
| 78 | #endif |
| 79 | check_cuda_error(cublasSetStream(cublas_handle, stream)); |
| 80 | cublasAlgoMap* cublas_algo_map = new cublasAlgoMap("gemm_config.in", ""); |
| 81 | |
| 82 | Allocator<AllocatorType::CUDA> allocator(getDevice()); |
| 83 | |
| 84 | std::mutex* cublas_wrapper_mutex = new std::mutex(); |
| 85 | #ifdef SPARSITY_ENABLED |
| 86 | cublasMMWrapper cublas_wrapper = cublasMMWrapper( |
| 87 | cublas_handle, cublaslt_handle, cusparselt_handle, stream, cublas_algo_map, cublas_wrapper_mutex, &allocator); |
| 88 | #else |
| 89 | cublasMMWrapper cublas_wrapper = |
| 90 | cublasMMWrapper(cublas_handle, cublaslt_handle, stream, cublas_algo_map, cublas_wrapper_mutex, &allocator); |
| 91 | #endif |
| 92 | if (std::is_same<T, half>::value) { |
| 93 | cublas_wrapper.setFP16GemmConfig(); |
| 94 | } |
| 95 | else if (std::is_same<T, float>::value) { |
| 96 | cublas_wrapper.setFP32GemmConfig(); |
| 97 | } |
| 98 | |
| 99 | WenetDecoderWeight<T> wenet_Decoder_weights(head_num, size_per_head, inter_size, num_layers, vocab_size, max_len); |
| 100 | // std::string paraFilePath = "/target/python/dec/bin_model/"; |
| 101 | // wenet_Decoder_weights->loadModel(paraFilePath); |
| 102 | WenetDecoder<T> wenet_Decoder = WenetDecoder<T>(0, // max_batch_size_, deprecated |
| 103 | 0, // max_seq_len_, deprecated |
| 104 | head_num, |
| 105 | size_per_head, |
| 106 | inter_size, |
| 107 | num_layers, |
| 108 | vocab_size, |
| 109 | max_len, |
| 110 | q_scaling, |
nothing calls this directly
no test coverage detected