MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / configurePlugin

Method configurePlugin

plugin/skipLayerNormPlugin/skipLayerNormPlugin.cpp:206–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206void SkipLayerNormPluginDynamic::configurePlugin(DynamicPluginTensorDesc const* inputs, int32_t nbInputs,
207 DynamicPluginTensorDesc const* outputs, int32_t nbOutputs) noexcept
208{
209 try
210 {
211 BERT_DEBUG_MSG("SkipLayerNormPluginDynamic configurePlugin");
212
213 // Validate input arguments
214 PLUGIN_VALIDATE(inputs != nullptr);
215 PLUGIN_VALIDATE(outputs != nullptr);
216 PLUGIN_VALIDATE(nbOutputs == 1);
217 PLUGIN_VALIDATE(nbInputs == 2);
218 if (mType == DataType::kFLOAT || mType == DataType::kHALF)
219 {
220 PLUGIN_VALIDATE(mType == inputs[0].desc.type);
221 PLUGIN_VALIDATE(mType == inputs[1].desc.type);
222 }
223 else
224 {
225 PLUGIN_VALIDATE(mType == inputs[0].desc.type || DataType::kFLOAT == inputs[0].desc.type);
226 PLUGIN_VALIDATE(mType == inputs[1].desc.type || DataType::kFLOAT == inputs[1].desc.type);
227 }
228 auto const& inDims0 = inputs[0].desc.dims;
229 auto const& inDims1 = inputs[1].desc.dims;
230 PLUGIN_VALIDATE(inDims0.nbDims == inDims1.nbDims);
231
232 PLUGIN_VALIDATE(std::equal(inDims0.d, inDims0.d + inDims0.nbDims, inDims1.d));
233
234 PLUGIN_VALIDATE(inDims0.nbDims == 5);
235 mLd = inDims0.d[HDIM]; // hiddensize
236 PLUGIN_VALIDATE(mLd != 0U);
237 PLUGIN_VALIDATE(inDims0.d[3] == 1);
238 PLUGIN_VALIDATE(inDims0.d[4] == 1);
239
240 mCfgType = inputs[0].desc.type == DataType::kINT8 ? DataType::kHALF : inputs[0].desc.type;
241
242 auto const paramType = getParamWordType(mCfgType);
243 mParamWordsize = getElementSize(paramType);
244 }
245 catch (std::exception const& e)
246 {
247 caughtError(e);
248 }
249}
250
251size_t SkipLayerNormPluginDynamic::getWorkspaceSize(
252 PluginTensorDesc const* inputs, int32_t nbInputs, PluginTensorDesc const* outputs, int32_t nbOutputs) const noexcept

Callers

nothing calls this directly

Calls 3

caughtErrorFunction · 0.85
getParamWordTypeFunction · 0.70
getElementSizeFunction · 0.50

Tested by

no test coverage detected