Вызов функции C ++ без достаточных параметров шаблона - PullRequest
2 голосов
/ 28 июня 2019

Когда я смотрел на 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) 

1 Ответ

1 голос
/ 28 июня 2019

Последние два параметра явно выводятся из аргументов функции. io_type от input и cell_params от params

...