message: remove the redundent add_elementwise in layernorm.
diff: @@ -10,68 +10,6 @@ namespace converters {
  namespace impl {
  namespace {
  -nvinfer1::ILayer* add_elementwise(
  - ConversionCtx* ctx,
  - nvinfer1::ElementWiseOperation op,
  - nvinfer1::ITensor* self,
  - nvinfer1::ITensor* other,
  - const std::string& name) {
  - // ensure self to have larger number of dimension
  - bool swapSelfOther = false;
  - if (self->getDimensions().nbDims < other->getDimensions().nbDims) {
  - std::swap(self, other);
  - swapSelfOther = true;
  - }
  - auto selfDim = util::toVec(self->getDimensions());
  - auto otherDim = util::toVec(other->getDimensions());
  - if (selfDim.size() != otherDim.size()) {
  - // other is with dynamic shape, need to expand its dimension now and get its
  - // shape at runtime
  - if (otherDim.end() != std::find(otherDim.begin(), otherDim.end(), -1)) {
  - auto thOtherStaticShapeMask = torch::ones(selfDim.size(), torch::kInt32);
  - auto thOtherDynamicShapeMask = torch::zeros(selfDim.size(), torch::kInt32);
  - for (size_t start = selfDim.size() - otherDim.size(), idx = 0; idx < otherDim.size(); ++idx) {
  - if (-1 != otherDim[idx]) {
  - thOtherStaticShapeMask[start + idx] = otherDim[idx];
  - } else {
  - thOtherStaticShapeMask[start + idx] = 0;
  - thOtherDynamicShapeMask[start + idx] = 1;
  - }
  - }
  - auto otherStaticShapeMask = tensor_to_const(ctx, thOtherStaticShapeMask);
  - auto otherDynamicShapeMask = tensor_to_const(ctx, thOtherDynamicShapeMask);
  - auto selfShape = ctx->net->addShape(*self)->getOutput(0);
  - // size of dynamic dimension of other need to the same as that of
  - // corresponding dimension of self
  - auto otherDynamicShape =
  - ctx->net->addElementWise(*selfShape, *otherDynamicShapeMask, nvinfer1::ElementWiseOperation::kPROD)
  - ->getOutput(0);
  - auto targetOtherShape =
  - ctx->net->addElementWise(*otherDynamicShape, *otherStaticShapeMask, nvinfer1::ElementWiseOperation::kSUM)
  - ->getOutput(0);
  -
  - auto otherShuffle = ctx->net->addShuffle(*other);
  - otherShuffle->setName(std::string("Reshape other tensor to have the same nDim as self for " + name).c_str());
  - otherShuffle->setInput(1, *targetOtherShape);
  - other = otherShuffle->getOutput(0);
  - } else {
  - // other is with static shape, expand dimension to make tow tensor have
  - // the same number of dimension
  - auto otherShuffle = ctx->net->addShuffle(*other);
  - otherShuffle->setReshapeDimensions(util::toDimsPad(otherDim, selfDim.size()));
  - other = otherShuffle->getOutput(0);
  - }
  - }
  - if (swapSelfOther) {
  - // swap back
  - std::swap(self, other);
  - swapSelfOther = false;
  - }
  - auto ele = ctx->net->addElementWise(*self, *other, op);
  - ele->setName(name.c_str());
  - return ele;
  -}
  -
  auto layer_norm_registrations TRTORCH_UNUSED = RegisterNodeConversionPatterns().pattern({
  R"SIG(aten::layer_norm(Tensor input, int[] normalized_shape, Tensor? gamma, Tensor? beta,
  float eps, bool cudnn_enabled) -> (Tensor))SIG",
  