没有足够模板参数的 C++ 函数调用

C++ function call without enough template parameters

当我查看 https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/RNN.cpp#L744 时,该函数被声明为采用 4 个模板参数,但在调用该函数时仅将 2 个参数传递给模板。在这种情况下,cell_params 和 io_type 来自哪里?

template<template<typename,typename> class LayerT, 
         template<typename,typename> class BidirLayerT, 
         typename cell_params, 
         typename io_type>
  std::tuple<io_type, Tensor, Tensor> _lstm_impl(
      const io_type& input,
      const std::vector<cell_params>& params, 
      const Tensor& hx, 
      const Tensor& cx,
      int64_t num_layers, 
      double dropout_p, 
      bool train, 
      bool bidirectional) {
    ...
}



auto results = _lstm_impl<FullLayer, FullBidirectionalLayer>(input, params, hx[0], hx[1], num_layers, dropout_p, train, bidirectional) 

最后两个参数显然是从函数参数中推导出来的。 io_type 来自 inputcell_params 来自 params