| 255 | } |
| 256 | |
| 257 | int32_t SkipLayerNormPluginDynamic::enqueue(PluginTensorDesc const* inputDesc, PluginTensorDesc const* outputDesc, |
| 258 | void const* const* inputs, void* const* outputs, void* workspace, cudaStream_t stream) noexcept |
| 259 | { |
| 260 | int32_t status = -1; |
| 261 | try |
| 262 | { |
| 263 | PLUGIN_VALIDATE(inputs != nullptr); |
| 264 | PLUGIN_VALIDATE(outputs != nullptr); |
| 265 | int32_t const inputVolume = volume(inputDesc[0].dims); |
| 266 | DataType iType = inputDesc->type; |
| 267 | |
| 268 | // Our plugin outputs only one tensor |
| 269 | // Launch CUDA kernel wrapper and save its return value |
| 270 | if (iType == DataType::kFLOAT) |
| 271 | { |
| 272 | auto const* const input = static_cast<float const*>(inputs[0]); |
| 273 | auto const* const skip = static_cast<float const*>(inputs[1]); |
| 274 | auto* output = static_cast<float*>(outputs[0]); |
| 275 | auto const* const bias = static_cast<float const*>(mBiasDev.get()); |
| 276 | auto const* const beta = static_cast<float const*>(mBetaDev.get()); |
| 277 | auto const* const gamma = static_cast<float const*>(mGammaDev.get()); |
| 278 | if (mHasBias) |
| 279 | { |
| 280 | status = computeSkipLayerNorm<float, true>( |
| 281 | stream, static_cast<int32_t>(mLd), inputVolume, input, skip, beta, gamma, output, bias); |
| 282 | } |
| 283 | else |
| 284 | { |
| 285 | status = computeSkipLayerNorm<float, false>( |
| 286 | stream, static_cast<int32_t>(mLd), inputVolume, input, skip, beta, gamma, output, bias); |
| 287 | } |
| 288 | } |
| 289 | else if (iType == DataType::kHALF) |
| 290 | { |
| 291 | auto const* const input = static_cast<half const*>(inputs[0]); |
| 292 | auto const* const skip = static_cast<half const*>(inputs[1]); |
| 293 | auto* output = static_cast<half*>(outputs[0]); |
| 294 | auto const* const bias = static_cast<half const*>(mBiasDev.get()); |
| 295 | auto const* const beta = static_cast<half const*>(mBetaDev.get()); |
| 296 | auto const* const gamma = static_cast<half const*>(mGammaDev.get()); |
| 297 | if (mHasBias) |
| 298 | { |
| 299 | status = computeSkipLayerNorm<half, true>( |
| 300 | stream, static_cast<int32_t>(mLd), inputVolume, input, skip, beta, gamma, output, bias); |
| 301 | } |
| 302 | else |
| 303 | { |
| 304 | status = computeSkipLayerNorm<half, false>( |
| 305 | stream, static_cast<int32_t>(mLd), inputVolume, input, skip, beta, gamma, output, bias); |
| 306 | } |
| 307 | } |
| 308 | else if (iType == DataType::kINT8) |
| 309 | { |
| 310 | float const dqScaleIn = inputDesc[0].scale; |
| 311 | float const dqScaleSkip = inputDesc[1].scale; |
| 312 | PLUGIN_VALIDATE(outputDesc[0].scale != 0.0F); |
| 313 | float const qScale = 1.F / outputDesc[0].scale; |
| 314 | auto const* const input = static_cast<int8_t const*>(inputs[0]); |
nothing calls this directly
no test coverage detected