\brief Converts RNN weights from TensorFlow's format to TensorRT's format. \param input Weights that are stored in TensorFlow's format. \return Converted weights in TensorRT's format. \note TensorFlow weight parameters for BasicLSTMCell are formatted as: Each [WR][icfo] is hiddenSize sequential elements. CellN Row 0: WiT, WcT, WfT, WoT CellN Row 1: WiT, WcT, WfT, WoT ... CellN RowM-1: WiT, Wc
| 449 | //! CellN: Wi, Wc, Wf, Wo, Ri, Rc, Rf, Ro |
| 450 | //! |
| 451 | nvinfer1::Weights SampleCharRNNBase::convertRNNWeights(nvinfer1::Weights orig, int dataSize) |
| 452 | { |
| 453 | nvinfer1::Weights input{orig.type, orig.values, (dataSize + mParams.hiddenSize) * 4 * mParams.hiddenSize}; |
| 454 | auto mem = new samplesCommon::FloatMemory(input.count); |
| 455 | weightsMemory.emplace_back(mem); |
| 456 | auto ptr = mem->raw(); |
| 457 | const float* data = static_cast<const float*>(input.values); |
| 458 | int dimsW[2]{dataSize, 4 * mParams.hiddenSize}; |
| 459 | int dimsR[2]{mParams.hiddenSize, 4 * mParams.hiddenSize}; |
| 460 | std::copy(data, data + input.count, ptr); |
| 461 | ASSERT(utils::transposeSubBuffers(ptr, DataType::kFLOAT, 1, dimsW[0], dimsW[1])); |
| 462 | ASSERT(utils::transposeSubBuffers(&ptr[dimsW[0] * dimsW[1]], DataType::kFLOAT, 1, dimsR[0], dimsR[1])); |
| 463 | return nvinfer1::Weights{input.type, ptr, input.count}; |
| 464 | } |
| 465 | |
| 466 | //! |
| 467 | //! \brief Converts RNN Biases from TensorFlow's format to TensorRT's format. |