| 308 | } |
| 309 | |
| 310 | int32_t EmbLayerNormPluginDynamic::enqueue(PluginTensorDesc const* inputDesc, PluginTensorDesc const* outputDesc, |
| 311 | void const* const* inputs, void* const* outputs, void* workspace, cudaStream_t stream) noexcept |
| 312 | { |
| 313 | try |
| 314 | { |
| 315 | int32_t const batchSize = inputDesc->dims.d[BDIM]; |
| 316 | int32_t const S = inputDesc->dims.d[SDIM]; |
| 317 | int32_t status = STATUS_FAILURE; |
| 318 | |
| 319 | // Our plugin outputs only one tensor |
| 320 | auto const inputIds = static_cast<int32_t const*>(inputs[0]); |
| 321 | auto const segmentIds = static_cast<int32_t const*>(inputs[1]); |
| 322 | auto const inputMask = static_cast<int32_t const*>(inputs[2]); |
| 323 | |
| 324 | float const* beta = mBetaDev.get(); |
| 325 | float const* gamma = mGammaDev.get(); |
| 326 | if (mType == DataType::kFLOAT) |
| 327 | { |
| 328 | auto output = static_cast<float*>(outputs[0]); |
| 329 | auto const wordEmb = static_cast<float const*>(mWordEmbDev.get()); |
| 330 | auto const tokEmb = static_cast<float const*>(mTokEmbDev.get()); |
| 331 | auto const posEmb = static_cast<float const*>(mPosEmbDev.get()); |
| 332 | status = embSkipLayerNorm<float>(stream, static_cast<int32_t>(mLd), batchSize, S, inputIds, segmentIds, |
| 333 | beta, gamma, wordEmb, posEmb, tokEmb, mWordVocabSize, mTokVocabSize, output); |
| 334 | |
| 335 | if (status != cudaSuccess) |
| 336 | { |
| 337 | return status; |
| 338 | } |
| 339 | } |
| 340 | else if (mType == DataType::kHALF) |
| 341 | { |
| 342 | auto output = static_cast<half*>(outputs[0]); |
| 343 | auto const wordEmb = static_cast<half const*>(mWordEmbDev.get()); |
| 344 | auto const tokEmb = static_cast<half const*>(mTokEmbDev.get()); |
| 345 | auto const posEmb = static_cast<half const*>(mPosEmbDev.get()); |
| 346 | status = embSkipLayerNorm<half>(stream, static_cast<int32_t>(mLd), batchSize, S, inputIds, segmentIds, beta, |
| 347 | gamma, wordEmb, posEmb, tokEmb, mWordVocabSize, mTokVocabSize, output); |
| 348 | |
| 349 | if (status != cudaSuccess) |
| 350 | { |
| 351 | return status; |
| 352 | } |
| 353 | } |
| 354 | else |
| 355 | { |
| 356 | gLogError << "Unsupported type error, expected [kHALF,kFLOAT], but received " << static_cast<int32_t>(mType) |
| 357 | << std::endl; |
| 358 | |
| 359 | return STATUS_NOT_SUPPORTED; |
| 360 | } |
| 361 | |
| 362 | // check mha use fused kernel |
| 363 | if (mUseFullMask || unfusedMaskSize != getMHAMaskPackedSize(mSM, mMhaType, S)) |
| 364 | { |
| 365 | size_t warps_m = 0, warps_n = 0, warps_k = 1; |
| 366 | if (S == 64 || S == 96 || S == 128) |
| 367 | { |
nothing calls this directly
no test coverage detected