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

Method EmbLayerNormPluginDynamic

plugin/embLayerNormPlugin/embLayerNormPlugin.cpp:45–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43REGISTER_TENSORRT_PLUGIN(EmbLayerNormPluginDynamicCreator);
44
45EmbLayerNormPluginDynamic::EmbLayerNormPluginDynamic(std::string const& name, DataType const type,
46 DataType const mhaType, Weights const& beta, Weights const& gamma, Weights const& wordEmb, Weights const& posEmb,
47 Weights const& tokEmb, bool const useFullMask)
48 : mLayerName(name)
49 , mLd(beta.count)
50 , mType(type)
51 , mUseFullMask(useFullMask)
52 , mMhaType(mhaType)
53{
54 // Assuming Weights.count is the number of elements and not bytes
55 PLUGIN_VALIDATE(beta.count == gamma.count);
56 PLUGIN_VALIDATE(mLd > 0U);
57 PLUGIN_VALIDATE(wordEmb.count % mLd == 0);
58 PLUGIN_VALIDATE(posEmb.count % mLd == 0);
59 PLUGIN_VALIDATE(tokEmb.count % mLd == 0);
60 mWordVocabSize = wordEmb.count / mLd;
61 mPosVocabSize = posEmb.count / mLd;
62 mTokVocabSize = tokEmb.count / mLd;
63 mSM = getSMVersion();
64 // mS is set during configure
65
66 mBeta.convertAndCopy(beta, nvinfer1::DataType::kFLOAT);
67 mGamma.convertAndCopy(gamma, nvinfer1::DataType::kFLOAT);
68 mWordEmb.convertAndCopy(wordEmb, mType);
69 mTokEmb.convertAndCopy(tokEmb, mType);
70 mPosEmb.convertAndCopy(posEmb, mType);
71
72 copyToDevice(mGamma, sizeof(float) * mGamma.count, mGammaDev);
73 copyToDevice(mBeta, sizeof(float) * mBeta.count, mBetaDev);
74 copyToDevice(mWordEmb, getWeightsSize(mWordEmb, mType), mWordEmbDev);
75 copyToDevice(mPosEmb, getWeightsSize(mPosEmb, mType), mPosEmbDev);
76 copyToDevice(mTokEmb, getWeightsSize(mTokEmb, mType), mTokEmbDev);
77}
78
79EmbLayerNormPluginDynamic::EmbLayerNormPluginDynamic(std::string const& name, void const* data, size_t length)
80 : mLayerName(name)

Callers

nothing calls this directly

Calls 5

copyToDeviceFunction · 0.85
getWeightsSizeFunction · 0.85
deserialize_valueFunction · 0.85
convertAndCopyMethod · 0.80
getSMVersionFunction · 0.50

Tested by

no test coverage detected