jiebi/CodeConvo huggingface dataset:
return ret; } <del> Variable VariableType::as_variable(Tensor tensor) const { </del> <ins> static Variable as_variable(Tensor tensor) { </ins> return make_variable(std::move(tensor)); } <del> std::tuple<Variable, Variable> VariableType::as_variable(std::tuple<Tensor, Tensor> tensors) const { </del> <ins> static std::tuple<Variable, Variable> as_variable(std::tuple<Tensor, Tensor> tensors) { </ins> return std::make_tuple<>( make_variable(std::move(std::get<0>(tensors))), make_variable(std::move(std::get<1>(tensors)))); } <del> std::tuple<Variable, Variable, Variable> VariableType::as_variable(std::tuple<Tensor, Tensor, Tensor> tensors) const { </del> <ins> static std::tuple<Variable, Variable, Variable> as_variable(std::tuple<Tensor, Tensor, Tensor> tensors) { </ins> return std::make_tuple<>( make_variable(std::move(std::get<0>(tensors))), make_variable(std::move(std::get<1>(tensors))), make_variable(std::move(std::get<2>(tensors)))); } <del> std::tuple<Variable, Variable, Variable, Variable> VariableType::as_variable(std::tuple<Tensor, Tensor, Tensor, Tensor> tensors) const { </del> <ins> static std::tuple<Variable, Variable, Variable, Variable> as_variable(std::tuple<Tensor, Tensor, Tensor, Tensor> tensors) { </ins> return std::make_tuple<>( make_variable(std::move(std::get<0>(tensors))), make_variable(std::move(std::get<1>(tensors))),
make_variable(std::move(std::get<3>(tensors)))); } <del> std::vector<Variable> VariableType::as_variable(TensorList tl) const { </del> <ins> static std::vector<Variable> as_variable(TensorList tl) { </ins> std::vector<Variable> variables; for (auto& t : tl) { variables.emplace_back(make_variable(std::move(t)));
} } <del> variable_list flatten(const TensorList& tensors) { </del> <ins> static variable_list flatten(const TensorList& tensors) { </ins> return cast_tensor_list(tensors); } <del> variable_list flatten(const Tensor& x, const TensorList& y) { </del> <ins> static variable_list flatten(const Tensor& x, const TensorList& y) { </ins> std::vector<Variable> r; r.reserve(1 + y.size()); r.emplace_back(x);
return self.clone(); } <del> std::vector<int64_t> to_arg_sizes(TensorList tensors, int64_t dim) { </del> <ins> static std::vector<int64_t> to_arg_sizes(TensorList tensors, int64_t dim) { </ins> std::vector<int64_t> arg_sizes(tensors.size()); for (size_t i = 0; i < tensors.size(); ++i) { arg_sizes[i] = tensors[i].size(dim);
std::vector<at::Tensor> unpack(at::TensorList tl, const char *name, int pos) const; std::vector<at::Tensor> unpack_idxs(at::TensorList tl, const char *name, int pos) const; <del> Variable as_variable(Tensor tensor) const; std::tuple<Variable, Variable> as_variable(std::tuple<Tensor, Tensor> tensor) const; std::tuple<Variable, Variable, Variable> as_variable(std::tuple<Tensor, Tensor, Tensor> tensor) const; std::tuple<Variable, Variable, Variable, Variable> as_variable(std::tuple<Tensor, Tensor, Tensor, Tensor> tensor) const; std::vector<Variable> as_variable(TensorList tensor) const; Variable maybe_wrap(Tensor data, const Variable & self, bool inplace) const; </del> private: at::Type* baseType; std::string str;
:members: <ins> Padding Layers -------------- :hidden:`ReflectionPad2d` ~~~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: ReflectionPad2d :members: :hidden:`ReplicationPad2d` ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: ReplicationPad2d :members: :hidden:`ReplicationPad3d` ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: ReplicationPad3d :members: :hidden:`ZeroPad2d` ~~~~~~~~~~~~~~~~~~~ .. autoclass:: ZeroPad2d :members: :hidden:`ConstantPad2d` ~~~~~~~~~~~~~~~~~~~~~~~ .. autoclass:: ConstantPad2d :members: </ins> Non-linear Activations ----------------------------------
(Cross, (), ((S, 3), (S, 3))), (Cross, (), ((S, 3, S), (S, 3, S), 1), 'dim'), (Inverse, (), ((S, S),), '', (), [skipIfNoLapack]), <ins> (Gesv, (), ((S, S), (S, S)), '', (), [skipIfNoLapack]), </ins> (Clone, (), ((S, M, S),)), (Squeeze, (), ((S, 1, M, 1),)), # TODO: enable neg dim checks
('cross', (S, 3), ((S, 3),)), ('cross', (S, 3, S), ((S, 3, S), 1), 'dim'), ('inverse', (S, S), (), '', (), [skipIfNoLapack]), <ins> ('gesv', (S, S), ((S, S),), '', (), [skipIfNoLapack]), </ins> ('clone', (S, M, S), ()), ('eq', (S, S, S), ((S, S, S),)), ('ne', (S, S, S), ((S, S, S),)),
def backward(ctx, grad_output): inverse, = ctx.saved_variables return -torch.mm(inverse.t(), torch.mm(grad_output, inverse.t())) <ins> class Gesv(Function): @staticmethod def forward(ctx, b, a): # TODO see if one can backprop through LU X, LU = torch.gesv(b, a) ctx.save_for_backward(X, a) ctx.mark_non_differentiable(LU) return X, LU @staticmethod def backward(ctx, grad_output, grad_LU=None): X, a = ctx.saved_variables grad_b, _ = torch.gesv(grad_output, a.t()) grad_a = -torch.mm(grad_b, X.t()) return grad_b, grad_a </ins>
>>> hx = Variable(torch.randn(3, 20)) >>> output = [] >>> for i in range(6): <del> ...     hx = rnn(input, hx) ...     output[i] = hx </del> <ins> ...     hx = rnn(input[i], hx) ...     output.append(hx) </ins> """ def __init__(self, input_size, hidden_size, bias=True, nonlinearity="tanh"):