Skip to content

Commit

Permalink
Correctly use channel dimension when creating Prelu node
Browse files Browse the repository at this point in the history
Signed-off-by: Rajeev Rao <[email protected]>
  • Loading branch information
kevinch-nv authored and rajeevsrao committed Dec 18, 2020
1 parent b4be515 commit 3c6fc92
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions parsers/caffe/caffeParser/opParsers/parsePReLU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ ILayer* parsePReLU(INetworkDefinition& network, const trtcaffe::LayerParameter&
{
return nullptr;
}
int nWeights = channelShared ? 1 : inputDims.d[1]; // Caffe treats second input dimension as channels
Dims slopesDims{inputDims.nbDims, {1}, {DimensionType::kSPATIAL}};
slopesDims.d[1] = nWeights;

int nWeights = channelShared ? 1 : inputDims.d[0]; // Caffe treats second input dimension as channels
Dims slopesDims{inputDims.nbDims, {}, {}};
std::fill(slopesDims.d, slopesDims.d + slopesDims.nbDims, 1);
slopesDims.d[0] = nWeights;

Weights w = weightFactory.isInitialized() ? weightFactory(msg.name(), WeightType::kGENERIC) :
weightFactory.allocateWeights(nWeights, std::uniform_real_distribution<float>(0.F, 1.F));
auto constLayer = network.addConstant(slopesDims, w);
return network.addParametricReLU(*tensors[msg.bottom(0)], *constLayer->getOutput(0));
}
} //namespace nvcaffeparser1
} //namespace nvcaffeparser1

0 comments on commit 3c6fc92

Please sign in to comment.