87 auto p_params = std::dynamic_pointer_cast<typename deeplima::eigen_impl::Op_BiLSTM<Eigen::MatrixXf, Eigen::VectorXf, float>::params_t>(
Parent::m_params[0]);
89 assert(p_params->layers.size() > 0);
90 const auto& layer = p_params->layers[0];
91 size_t hidden_size = layer.fw.weight_ih.rows() + layer.bw.weight_ih.rows();
96 const Eigen::MatrixXf& inputs,
97 Eigen::MatrixXf& outputs,
101 auto p_op = std::dynamic_pointer_cast<deeplima::eigen_impl::Op_BiLSTM<Eigen::MatrixXf, Eigen::VectorXf, float>>(
Parent::m_ops[0]);
131 const Eigen::MatrixXf& inputs,
132 const Eigen::MatrixXf& input_feats,
134 int64_t output_max_len,
136 std::vector< uint32_t >& output,
137 const std::vector<std::string>&
145#ifdef LEMM_INFERENCE_PROFILE
146 using clock = std::chrono::system_clock;
147 using ms = std::chrono::duration<double, std::milli>;
152 auto p_linear_feats_enc = std::dynamic_pointer_cast<deeplima::eigen_impl::Op_Linear<Eigen::MatrixXf, Eigen::VectorXf, float>>(
Parent::m_ops[5]);
154#ifdef LEMM_INFERENCE_PROFILE
155 const auto before = clock::now();
163#ifdef LEMM_INFERENCE_PROFILE
164 const auto exec1 = clock::now();
168 auto p_linear_feats_dec = std::dynamic_pointer_cast<deeplima::eigen_impl::Op_Linear<Eigen::MatrixXf, Eigen::VectorXf, float>>(
Parent::m_ops[3]);
174#ifdef LEMM_INFERENCE_PROFILE
175 const auto exec2 = clock::now();
177 auto p_encoder = std::dynamic_pointer_cast<deeplima::eigen_impl::Op_BiLSTM<Eigen::MatrixXf, Eigen::VectorXf, float>>(
Parent::m_ops[0]);
179 auto p_decoder = std::dynamic_pointer_cast<deeplima::eigen_impl::Op_LSTM_Beam_Decoder<Eigen::MatrixXf, Eigen::VectorXf, float>>(
Parent::m_ops[4]);
181 auto enc_mutlilayer_bilstm
182 = std::dynamic_pointer_cast<const deeplima::eigen_impl::params_multilayer_bilstm_t<Eigen::MatrixXf, Eigen::VectorXf>>(
Parent::m_params[0]);
183 size_t hidden_size = enc_mutlilayer_bilstm->layers[0].fw.weight_ih.rows() / 4;
197#ifdef LEMM_INFERENCE_PROFILE
198 std::cerr <<
"inputs.cols()=" << inputs.cols() << std::endl;
199 std::cerr <<
"inputs.rows()=" << inputs.rows() << std::endl;
201 const auto exec3 = clock::now();
208#ifdef LEMM_INFERENCE_PROFILE
209 const auto exec4 = clock::now();
218 auto p_linear_h = std::dynamic_pointer_cast<deeplima::eigen_impl::Op_Linear<Eigen::MatrixXf, Eigen::VectorXf, float>>(
Parent::m_ops[1]);
219 auto p_linear_c = std::dynamic_pointer_cast<deeplima::eigen_impl::Op_Linear<Eigen::MatrixXf, Eigen::VectorXf, float>>(
Parent::m_ops[2]);
221#ifdef LEMM_INFERENCE_PROFILE
222 const auto exec5 = clock::now();
227#ifdef LEMM_INFERENCE_PROFILE
228 const auto exec6 = clock::now();
233#ifdef LEMM_INFERENCE_PROFILE
234 const auto exec7 = clock::now();
238 p_decoder->execute(
Parent::m_wb[4][worker_id], decoder_embd,
242#ifdef LEMM_INFERENCE_PROFILE
243 const auto exec8 = clock::now();
245 std::cerr <<
"feats for enc : " << (exec1 - before).count() << std::endl;
246 std::cerr <<
"feats for dec : " << (exec2 - exec1).count() << std::endl;
248 std::cerr <<
"copy : " << (exec3 - exec2).count() << std::endl;
249 std::cerr <<
"encoder : " << (exec4 - exec3).count() << std::endl;
250 std::cerr <<
"copy : " << (exec5 - exec4).count() << std::endl;
252 std::cerr <<
"prep h : " << (exec6 - exec5).count() << std::endl;
253 std::cerr <<
"prep c : " << (exec7 - exec6).count() << std::endl;
254 std::cerr <<
"decoder : " << (exec8 - exec7).count() << std::endl;