When creating autograph extensions in C++ by subclassing the torch::autograd::Function…
From the comments here, it seems that only direct Variable arguments are registered in the graph.

  
      github.com
  
  
    pytorch/pytorch/blob/master/torch/csrc/autograd/custom_function.h#L28-L35 5

/// `forward` can take as many arguments as you want and should return either a
/// variable list or a Variable. Use of any direct Variable arguments will be
/// registered in the graph but no vectors/sets or any other data structures will
/// be traversed. It should take a pointer to `torch::autograd::AutogradContext`
/// as the first argument. Variables can be saved in the `ctx` using `ctx->save_for_backward`
/// (see `torch::autograd::AutogradContext::save_for_backward`) and other data
/// can be saved in the `ctx->saved_data` map (see `torch::autograd::AutogradContext::saved_data`)
/// in the form of `<std::string, at::IValue>` pairs.



  
  
    
    
  
  


Is there any way I could pass a variable_list here? We are building a general interface for libtorch in R, and we only know the number of Variable argument at runtime. I see that python uses a different implementation here 1 that uses a variable_list.