torch-rb 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +5 -3
  4. data/ext/torch/ext.cpp +22 -548
  5. data/ext/torch/extconf.rb +6 -0
  6. data/ext/torch/nn_functions.cpp +595 -0
  7. data/ext/torch/nn_functions.hpp +6 -0
  8. data/ext/torch/templates.hpp +250 -0
  9. data/ext/torch/tensor_functions.cpp +1860 -0
  10. data/ext/torch/tensor_functions.hpp +6 -0
  11. data/ext/torch/torch_functions.cpp +2875 -0
  12. data/ext/torch/torch_functions.hpp +6 -0
  13. data/lib/torch.rb +68 -129
  14. data/lib/torch/ext.bundle +0 -0
  15. data/lib/torch/native/dispatcher.rb +48 -0
  16. data/lib/torch/native/function.rb +78 -0
  17. data/lib/torch/native/generator.rb +149 -0
  18. data/lib/torch/native/native_functions.yaml +6837 -0
  19. data/lib/torch/native/parser.rb +97 -0
  20. data/lib/torch/nn/bce_with_logits_loss.rb +15 -0
  21. data/lib/torch/nn/conv2d.rb +0 -2
  22. data/lib/torch/nn/cosine_embedding_loss.rb +14 -0
  23. data/lib/torch/nn/functional.rb +55 -16
  24. data/lib/torch/nn/hinge_embedding_loss.rb +14 -0
  25. data/lib/torch/nn/identity.rb +1 -0
  26. data/lib/torch/nn/margin_ranking_loss.rb +14 -0
  27. data/lib/torch/nn/module.rb +59 -12
  28. data/lib/torch/nn/multi_label_margin_loss.rb +13 -0
  29. data/lib/torch/nn/multi_label_soft_margin_loss.rb +13 -0
  30. data/lib/torch/nn/multi_margin_loss.rb +17 -0
  31. data/lib/torch/nn/parameter.rb +4 -0
  32. data/lib/torch/nn/rnn.rb +22 -0
  33. data/lib/torch/nn/rnn_base.rb +154 -0
  34. data/lib/torch/nn/smooth_l1_loss.rb +13 -0
  35. data/lib/torch/nn/soft_margin_loss.rb +13 -0
  36. data/lib/torch/nn/triplet_margin_loss.rb +18 -0
  37. data/lib/torch/tensor.rb +19 -19
  38. data/lib/torch/version.rb +1 -1
  39. metadata +26 -2
data/ext/torch/extconf.rb CHANGED
@@ -22,4 +22,10 @@ $LDFLAGS << " -Wl,-rpath,#{lib}"
22
22
  $LDFLAGS << " -L#{lib}"
23
23
  $LDFLAGS << " -ltorch -lc10"
24
24
 
25
+ # generate C++ functions
26
+ puts "Generating C++ functions..."
27
+ require_relative "../../lib/torch/native/generator"
28
+ Torch::Native::Generator.generate_cpp_functions
29
+
30
+ # create makefile
25
31
  create_makefile("torch/ext")
@@ -0,0 +1,595 @@
1
+ // generated by rake generate:functions
2
+ // do not edit by hand
3
+
4
+ #include <torch/torch.h>
5
+ #include <rice/Module.hpp>
6
+ #include "templates.hpp"
7
+
8
+ void add_nn_functions(Module m) {
9
+ m
10
+ .define_singleton_method(
11
+ "_adaptive_avg_pool2d",
12
+ *[](const Tensor &self, IntArrayRef output_size) {
13
+ return torch::adaptive_avg_pool2d(self, output_size);
14
+ })
15
+ .define_singleton_method(
16
+ "_adaptive_avg_pool2d_out",
17
+ *[](const Tensor &self, IntArrayRef output_size, Tensor &out) {
18
+ return torch::adaptive_avg_pool2d_out(out, self, output_size);
19
+ })
20
+ .define_singleton_method(
21
+ "_adaptive_avg_pool3d",
22
+ *[](const Tensor &self, IntArrayRef output_size) {
23
+ return torch::adaptive_avg_pool3d(self, output_size);
24
+ })
25
+ .define_singleton_method(
26
+ "_adaptive_avg_pool3d_out",
27
+ *[](const Tensor &self, IntArrayRef output_size, Tensor &out) {
28
+ return torch::adaptive_avg_pool3d_out(out, self, output_size);
29
+ })
30
+ .define_singleton_method(
31
+ "_adaptive_max_pool2d",
32
+ *[](const Tensor &self, IntArrayRef output_size) {
33
+ return torch::adaptive_max_pool2d(self, output_size);
34
+ })
35
+ .define_singleton_method(
36
+ "_adaptive_max_pool2d_out",
37
+ *[](const Tensor &self, IntArrayRef output_size, Tensor &out, Tensor &indices) {
38
+ return torch::adaptive_max_pool2d_out(out, indices, self, output_size);
39
+ })
40
+ .define_singleton_method(
41
+ "_adaptive_max_pool3d",
42
+ *[](const Tensor &self, IntArrayRef output_size) {
43
+ return torch::adaptive_max_pool3d(self, output_size);
44
+ })
45
+ .define_singleton_method(
46
+ "_adaptive_max_pool3d_out",
47
+ *[](const Tensor &self, IntArrayRef output_size, Tensor &out, Tensor &indices) {
48
+ return torch::adaptive_max_pool3d_out(out, indices, self, output_size);
49
+ })
50
+ .define_singleton_method(
51
+ "_binary_cross_entropy",
52
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction) {
53
+ return torch::binary_cross_entropy(self, target, weight, reduction);
54
+ })
55
+ .define_singleton_method(
56
+ "_binary_cross_entropy_out",
57
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction, Tensor &out) {
58
+ return torch::binary_cross_entropy_out(out, self, target, weight, reduction);
59
+ })
60
+ .define_singleton_method(
61
+ "_col2im",
62
+ *[](const Tensor &self, IntArrayRef output_size, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) {
63
+ return torch::col2im(self, output_size, kernel_size, dilation, padding, stride);
64
+ })
65
+ .define_singleton_method(
66
+ "_col2im_out",
67
+ *[](const Tensor &self, IntArrayRef output_size, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride, Tensor &out) {
68
+ return torch::col2im_out(out, self, output_size, kernel_size, dilation, padding, stride);
69
+ })
70
+ .define_singleton_method(
71
+ "_elu",
72
+ *[](const Tensor &self, Scalar alpha, Scalar scale, Scalar input_scale) {
73
+ return torch::elu(self, alpha, scale, input_scale);
74
+ })
75
+ .define_singleton_method(
76
+ "_elu_",
77
+ *[](Tensor &self, Scalar alpha, Scalar scale, Scalar input_scale) {
78
+ return torch::elu_(self, alpha, scale, input_scale);
79
+ })
80
+ .define_singleton_method(
81
+ "_elu_out",
82
+ *[](const Tensor &self, Scalar alpha, Scalar scale, Scalar input_scale, Tensor &out) {
83
+ return torch::elu_out(out, self, alpha, scale, input_scale);
84
+ })
85
+ .define_singleton_method(
86
+ "_fractional_max_pool2d",
87
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor &random_samples) {
88
+ return torch::fractional_max_pool2d(self, kernel_size, output_size, random_samples);
89
+ })
90
+ .define_singleton_method(
91
+ "_fractional_max_pool2d_output",
92
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor &random_samples, Tensor &output, Tensor &indices) {
93
+ return torch::fractional_max_pool2d_out(output, indices, self, kernel_size, output_size, random_samples);
94
+ })
95
+ .define_singleton_method(
96
+ "_fractional_max_pool3d",
97
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor &random_samples) {
98
+ return torch::fractional_max_pool3d(self, kernel_size, output_size, random_samples);
99
+ })
100
+ .define_singleton_method(
101
+ "_fractional_max_pool3d_output",
102
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor &random_samples, Tensor &output, Tensor &indices) {
103
+ return torch::fractional_max_pool3d_out(output, indices, self, kernel_size, output_size, random_samples);
104
+ })
105
+ .define_singleton_method(
106
+ "_gelu",
107
+ *[](const Tensor &self) {
108
+ return torch::gelu(self);
109
+ })
110
+ .define_singleton_method(
111
+ "_glu",
112
+ *[](const Tensor &self, int64_t dim) {
113
+ return torch::glu(self, dim);
114
+ })
115
+ .define_singleton_method(
116
+ "_glu_out",
117
+ *[](const Tensor &self, int64_t dim, Tensor &out) {
118
+ return torch::glu_out(out, self, dim);
119
+ })
120
+ .define_singleton_method(
121
+ "_hardtanh",
122
+ *[](const Tensor &self, Scalar min_val, Scalar max_val) {
123
+ return torch::hardtanh(self, min_val, max_val);
124
+ })
125
+ .define_singleton_method(
126
+ "_hardtanh_",
127
+ *[](Tensor &self, Scalar min_val, Scalar max_val) {
128
+ return torch::hardtanh_(self, min_val, max_val);
129
+ })
130
+ .define_singleton_method(
131
+ "_hardtanh_out",
132
+ *[](const Tensor &self, Scalar min_val, Scalar max_val, Tensor &out) {
133
+ return torch::hardtanh_out(out, self, min_val, max_val);
134
+ })
135
+ .define_singleton_method(
136
+ "_im2col",
137
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) {
138
+ return torch::im2col(self, kernel_size, dilation, padding, stride);
139
+ })
140
+ .define_singleton_method(
141
+ "_im2col_out",
142
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride, Tensor &out) {
143
+ return torch::im2col_out(out, self, kernel_size, dilation, padding, stride);
144
+ })
145
+ .define_singleton_method(
146
+ "_l1_loss",
147
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction) {
148
+ return torch::l1_loss(self, target, reduction);
149
+ })
150
+ .define_singleton_method(
151
+ "_l1_loss_out",
152
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction, Tensor &out) {
153
+ return torch::l1_loss_out(out, self, target, reduction);
154
+ })
155
+ .define_singleton_method(
156
+ "_leaky_relu",
157
+ *[](const Tensor &self, Scalar negative_slope) {
158
+ return torch::leaky_relu(self, negative_slope);
159
+ })
160
+ .define_singleton_method(
161
+ "_leaky_relu_",
162
+ *[](Tensor &self, Scalar negative_slope) {
163
+ return torch::leaky_relu_(self, negative_slope);
164
+ })
165
+ .define_singleton_method(
166
+ "_leaky_relu_out",
167
+ *[](const Tensor &self, Scalar negative_slope, Tensor &out) {
168
+ return torch::leaky_relu_out(out, self, negative_slope);
169
+ })
170
+ .define_singleton_method(
171
+ "_linear",
172
+ *[](const Tensor &input, const Tensor &weight, OptionalTensor bias) {
173
+ return torch::linear(input, weight, bias);
174
+ })
175
+ .define_singleton_method(
176
+ "_log_sigmoid",
177
+ *[](const Tensor &self) {
178
+ return torch::log_sigmoid(self);
179
+ })
180
+ .define_singleton_method(
181
+ "_log_sigmoid_forward",
182
+ *[](const Tensor &self) {
183
+ return torch::log_sigmoid_forward(self);
184
+ })
185
+ .define_singleton_method(
186
+ "_log_sigmoid_forward_output",
187
+ *[](const Tensor &self, Tensor &output, Tensor &buffer) {
188
+ return torch::log_sigmoid_forward_out(output, buffer, self);
189
+ })
190
+ .define_singleton_method(
191
+ "_log_sigmoid_out",
192
+ *[](const Tensor &self, Tensor &out) {
193
+ return torch::log_sigmoid_out(out, self);
194
+ })
195
+ .define_singleton_method(
196
+ "_max_pool2d_with_indices",
197
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) {
198
+ return torch::max_pool2d_with_indices(self, kernel_size, stride, padding, dilation, ceil_mode);
199
+ })
200
+ .define_singleton_method(
201
+ "_max_pool2d_with_indices_out",
202
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode, Tensor &out, Tensor &indices) {
203
+ return torch::max_pool2d_with_indices_out(out, indices, self, kernel_size, stride, padding, dilation, ceil_mode);
204
+ })
205
+ .define_singleton_method(
206
+ "_max_pool3d_with_indices",
207
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) {
208
+ return torch::max_pool3d_with_indices(self, kernel_size, stride, padding, dilation, ceil_mode);
209
+ })
210
+ .define_singleton_method(
211
+ "_max_pool3d_with_indices_out",
212
+ *[](const Tensor &self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode, Tensor &out, Tensor &indices) {
213
+ return torch::max_pool3d_with_indices_out(out, indices, self, kernel_size, stride, padding, dilation, ceil_mode);
214
+ })
215
+ .define_singleton_method(
216
+ "_max_unpool2d",
217
+ *[](const Tensor &self, const Tensor &indices, IntArrayRef output_size) {
218
+ return torch::max_unpool2d(self, indices, output_size);
219
+ })
220
+ .define_singleton_method(
221
+ "_max_unpool2d_out",
222
+ *[](const Tensor &self, const Tensor &indices, IntArrayRef output_size, Tensor &out) {
223
+ return torch::max_unpool2d_out(out, self, indices, output_size);
224
+ })
225
+ .define_singleton_method(
226
+ "_max_unpool3d",
227
+ *[](const Tensor &self, const Tensor &indices, IntArrayRef output_size, IntArrayRef stride, IntArrayRef padding) {
228
+ return torch::max_unpool3d(self, indices, output_size, stride, padding);
229
+ })
230
+ .define_singleton_method(
231
+ "_max_unpool3d_out",
232
+ *[](const Tensor &self, const Tensor &indices, IntArrayRef output_size, IntArrayRef stride, IntArrayRef padding, Tensor &out) {
233
+ return torch::max_unpool3d_out(out, self, indices, output_size, stride, padding);
234
+ })
235
+ .define_singleton_method(
236
+ "_mkldnn_linear",
237
+ *[](const Tensor &input, const Tensor &weight, OptionalTensor bias) {
238
+ return torch::mkldnn_linear(input, weight, bias);
239
+ })
240
+ .define_singleton_method(
241
+ "_mkldnn_reorder_conv2d_weight",
242
+ *[](const Tensor &self, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups) {
243
+ return torch::mkldnn_reorder_conv2d_weight(self, padding, stride, dilation, groups);
244
+ })
245
+ .define_singleton_method(
246
+ "_mse_loss",
247
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction) {
248
+ return torch::mse_loss(self, target, reduction);
249
+ })
250
+ .define_singleton_method(
251
+ "_mse_loss_out",
252
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction, Tensor &out) {
253
+ return torch::mse_loss_out(out, self, target, reduction);
254
+ })
255
+ .define_singleton_method(
256
+ "_multi_margin_loss",
257
+ *[](const Tensor &self, const Tensor &target, Scalar p, Scalar margin, OptionalTensor weight, MyReduction reduction) {
258
+ return torch::multi_margin_loss(self, target, p, margin, weight, reduction);
259
+ })
260
+ .define_singleton_method(
261
+ "_multi_margin_loss_out",
262
+ *[](const Tensor &self, const Tensor &target, Scalar p, Scalar margin, OptionalTensor weight, MyReduction reduction, Tensor &out) {
263
+ return torch::multi_margin_loss_out(out, self, target, p, margin, weight, reduction);
264
+ })
265
+ .define_singleton_method(
266
+ "_multilabel_margin_loss",
267
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction) {
268
+ return torch::multilabel_margin_loss(self, target, reduction);
269
+ })
270
+ .define_singleton_method(
271
+ "_multilabel_margin_loss_forward",
272
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction) {
273
+ return torch::multilabel_margin_loss_forward(self, target, reduction);
274
+ })
275
+ .define_singleton_method(
276
+ "_multilabel_margin_loss_forward_output",
277
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction, Tensor &output, Tensor &is_target) {
278
+ return torch::multilabel_margin_loss_forward_out(output, is_target, self, target, reduction);
279
+ })
280
+ .define_singleton_method(
281
+ "_multilabel_margin_loss_out",
282
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction, Tensor &out) {
283
+ return torch::multilabel_margin_loss_out(out, self, target, reduction);
284
+ })
285
+ .define_singleton_method(
286
+ "_nll_loss",
287
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction, int64_t ignore_index) {
288
+ return torch::nll_loss(self, target, weight, reduction, ignore_index);
289
+ })
290
+ .define_singleton_method(
291
+ "_nll_loss2d",
292
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction, int64_t ignore_index) {
293
+ return torch::nll_loss2d(self, target, weight, reduction, ignore_index);
294
+ })
295
+ .define_singleton_method(
296
+ "_nll_loss2d_forward",
297
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction, int64_t ignore_index) {
298
+ return torch::nll_loss2d_forward(self, target, weight, reduction, ignore_index);
299
+ })
300
+ .define_singleton_method(
301
+ "_nll_loss2d_forward_output",
302
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction, int64_t ignore_index, Tensor &output, Tensor &total_weight) {
303
+ return torch::nll_loss2d_forward_out(output, total_weight, self, target, weight, reduction, ignore_index);
304
+ })
305
+ .define_singleton_method(
306
+ "_nll_loss2d_out",
307
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction, int64_t ignore_index, Tensor &out) {
308
+ return torch::nll_loss2d_out(out, self, target, weight, reduction, ignore_index);
309
+ })
310
+ .define_singleton_method(
311
+ "_nll_loss_forward",
312
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction, int64_t ignore_index) {
313
+ return torch::nll_loss_forward(self, target, weight, reduction, ignore_index);
314
+ })
315
+ .define_singleton_method(
316
+ "_nll_loss_forward_output",
317
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction, int64_t ignore_index, Tensor &output, Tensor &total_weight) {
318
+ return torch::nll_loss_forward_out(output, total_weight, self, target, weight, reduction, ignore_index);
319
+ })
320
+ .define_singleton_method(
321
+ "_nll_loss_out",
322
+ *[](const Tensor &self, const Tensor &target, OptionalTensor weight, MyReduction reduction, int64_t ignore_index, Tensor &out) {
323
+ return torch::nll_loss_out(out, self, target, weight, reduction, ignore_index);
324
+ })
325
+ .define_singleton_method(
326
+ "_one_hot",
327
+ *[](const Tensor &self, int64_t num_classes) {
328
+ return torch::one_hot(self, num_classes);
329
+ })
330
+ .define_singleton_method(
331
+ "_reflection_pad1d",
332
+ *[](const Tensor &self, IntArrayRef padding) {
333
+ return torch::reflection_pad1d(self, padding);
334
+ })
335
+ .define_singleton_method(
336
+ "_reflection_pad1d_out",
337
+ *[](const Tensor &self, IntArrayRef padding, Tensor &out) {
338
+ return torch::reflection_pad1d_out(out, self, padding);
339
+ })
340
+ .define_singleton_method(
341
+ "_reflection_pad2d",
342
+ *[](const Tensor &self, IntArrayRef padding) {
343
+ return torch::reflection_pad2d(self, padding);
344
+ })
345
+ .define_singleton_method(
346
+ "_reflection_pad2d_out",
347
+ *[](const Tensor &self, IntArrayRef padding, Tensor &out) {
348
+ return torch::reflection_pad2d_out(out, self, padding);
349
+ })
350
+ .define_singleton_method(
351
+ "_replication_pad1d",
352
+ *[](const Tensor &self, IntArrayRef padding) {
353
+ return torch::replication_pad1d(self, padding);
354
+ })
355
+ .define_singleton_method(
356
+ "_replication_pad1d_out",
357
+ *[](const Tensor &self, IntArrayRef padding, Tensor &out) {
358
+ return torch::replication_pad1d_out(out, self, padding);
359
+ })
360
+ .define_singleton_method(
361
+ "_replication_pad2d",
362
+ *[](const Tensor &self, IntArrayRef padding) {
363
+ return torch::replication_pad2d(self, padding);
364
+ })
365
+ .define_singleton_method(
366
+ "_replication_pad2d_out",
367
+ *[](const Tensor &self, IntArrayRef padding, Tensor &out) {
368
+ return torch::replication_pad2d_out(out, self, padding);
369
+ })
370
+ .define_singleton_method(
371
+ "_replication_pad3d",
372
+ *[](const Tensor &self, IntArrayRef padding) {
373
+ return torch::replication_pad3d(self, padding);
374
+ })
375
+ .define_singleton_method(
376
+ "_replication_pad3d_out",
377
+ *[](const Tensor &self, IntArrayRef padding, Tensor &out) {
378
+ return torch::replication_pad3d_out(out, self, padding);
379
+ })
380
+ .define_singleton_method(
381
+ "_rrelu_with_noise",
382
+ *[](const Tensor &self, const Tensor &noise, Scalar lower, Scalar upper, bool training) {
383
+ return torch::rrelu_with_noise(self, noise, lower, upper, training);
384
+ })
385
+ .define_singleton_method(
386
+ "_rrelu_with_noise_",
387
+ *[](Tensor &self, const Tensor &noise, Scalar lower, Scalar upper, bool training) {
388
+ return torch::rrelu_with_noise_(self, noise, lower, upper, training);
389
+ })
390
+ .define_singleton_method(
391
+ "_rrelu_with_noise_out",
392
+ *[](const Tensor &self, const Tensor &noise, Scalar lower, Scalar upper, bool training, Tensor &out) {
393
+ return torch::rrelu_with_noise_out(out, self, noise, lower, upper, training);
394
+ })
395
+ .define_singleton_method(
396
+ "_slow_conv_dilated2d",
397
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) {
398
+ return torch::slow_conv_dilated2d(self, weight, kernel_size, bias, stride, padding, dilation);
399
+ })
400
+ .define_singleton_method(
401
+ "_slow_conv_dilated3d",
402
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) {
403
+ return torch::slow_conv_dilated3d(self, weight, kernel_size, bias, stride, padding, dilation);
404
+ })
405
+ .define_singleton_method(
406
+ "_slow_conv_transpose2d",
407
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation) {
408
+ return torch::slow_conv_transpose2d(self, weight, kernel_size, bias, stride, padding, output_padding, dilation);
409
+ })
410
+ .define_singleton_method(
411
+ "_slow_conv_transpose2d_out",
412
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation, Tensor &out) {
413
+ return torch::slow_conv_transpose2d_out(out, self, weight, kernel_size, bias, stride, padding, output_padding, dilation);
414
+ })
415
+ .define_singleton_method(
416
+ "_slow_conv_transpose3d",
417
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation) {
418
+ return torch::slow_conv_transpose3d(self, weight, kernel_size, bias, stride, padding, output_padding, dilation);
419
+ })
420
+ .define_singleton_method(
421
+ "_slow_conv_transpose3d_out",
422
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation, Tensor &out) {
423
+ return torch::slow_conv_transpose3d_out(out, self, weight, kernel_size, bias, stride, padding, output_padding, dilation);
424
+ })
425
+ .define_singleton_method(
426
+ "_smooth_l1_loss",
427
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction) {
428
+ return torch::smooth_l1_loss(self, target, reduction);
429
+ })
430
+ .define_singleton_method(
431
+ "_smooth_l1_loss_out",
432
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction, Tensor &out) {
433
+ return torch::smooth_l1_loss_out(out, self, target, reduction);
434
+ })
435
+ .define_singleton_method(
436
+ "_soft_margin_loss",
437
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction) {
438
+ return torch::soft_margin_loss(self, target, reduction);
439
+ })
440
+ .define_singleton_method(
441
+ "_soft_margin_loss_out",
442
+ *[](const Tensor &self, const Tensor &target, MyReduction reduction, Tensor &out) {
443
+ return torch::soft_margin_loss_out(out, self, target, reduction);
444
+ })
445
+ .define_singleton_method(
446
+ "_softplus",
447
+ *[](const Tensor &self, Scalar beta, Scalar threshold) {
448
+ return torch::softplus(self, beta, threshold);
449
+ })
450
+ .define_singleton_method(
451
+ "_softplus_out",
452
+ *[](const Tensor &self, Scalar beta, Scalar threshold, Tensor &out) {
453
+ return torch::softplus_out(out, self, beta, threshold);
454
+ })
455
+ .define_singleton_method(
456
+ "_softshrink",
457
+ *[](const Tensor &self, Scalar lambd) {
458
+ return torch::softshrink(self, lambd);
459
+ })
460
+ .define_singleton_method(
461
+ "_softshrink_out",
462
+ *[](const Tensor &self, Scalar lambd, Tensor &out) {
463
+ return torch::softshrink_out(out, self, lambd);
464
+ })
465
+ .define_singleton_method(
466
+ "_thnn_conv2d",
467
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding) {
468
+ return torch::thnn_conv2d(self, weight, kernel_size, bias, stride, padding);
469
+ })
470
+ .define_singleton_method(
471
+ "_thnn_conv2d_forward",
472
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding) {
473
+ return torch::thnn_conv2d_forward(self, weight, kernel_size, bias, stride, padding);
474
+ })
475
+ .define_singleton_method(
476
+ "_thnn_conv2d_forward_output",
477
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, Tensor &output, Tensor &finput, Tensor &fgrad_input) {
478
+ return torch::thnn_conv2d_forward_out(output, finput, fgrad_input, self, weight, kernel_size, bias, stride, padding);
479
+ })
480
+ .define_singleton_method(
481
+ "_thnn_conv2d_out",
482
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, Tensor &out) {
483
+ return torch::thnn_conv2d_out(out, self, weight, kernel_size, bias, stride, padding);
484
+ })
485
+ .define_singleton_method(
486
+ "_thnn_conv3d",
487
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding) {
488
+ return torch::thnn_conv3d(self, weight, kernel_size, bias, stride, padding);
489
+ })
490
+ .define_singleton_method(
491
+ "_thnn_conv3d_forward",
492
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding) {
493
+ return torch::thnn_conv3d_forward(self, weight, kernel_size, bias, stride, padding);
494
+ })
495
+ .define_singleton_method(
496
+ "_thnn_conv3d_forward_output",
497
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, Tensor &output, Tensor &finput, Tensor &fgrad_input) {
498
+ return torch::thnn_conv3d_forward_out(output, finput, fgrad_input, self, weight, kernel_size, bias, stride, padding);
499
+ })
500
+ .define_singleton_method(
501
+ "_thnn_conv3d_out",
502
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, Tensor &out) {
503
+ return torch::thnn_conv3d_out(out, self, weight, kernel_size, bias, stride, padding);
504
+ })
505
+ .define_singleton_method(
506
+ "_thnn_conv_depthwise2d",
507
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) {
508
+ return torch::thnn_conv_depthwise2d(self, weight, kernel_size, bias, stride, padding, dilation);
509
+ })
510
+ .define_singleton_method(
511
+ "_thnn_conv_depthwise2d_forward",
512
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) {
513
+ return torch::thnn_conv_depthwise2d_forward(self, weight, kernel_size, bias, stride, padding, dilation);
514
+ })
515
+ .define_singleton_method(
516
+ "_thnn_conv_depthwise2d_forward_out",
517
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, Tensor &out) {
518
+ return torch::thnn_conv_depthwise2d_forward_out(out, self, weight, kernel_size, bias, stride, padding, dilation);
519
+ })
520
+ .define_singleton_method(
521
+ "_thnn_conv_depthwise2d_out",
522
+ *[](const Tensor &self, const Tensor &weight, IntArrayRef kernel_size, OptionalTensor bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, Tensor &out) {
523
+ return torch::thnn_conv_depthwise2d_out(out, self, weight, kernel_size, bias, stride, padding, dilation);
524
+ })
525
+ .define_singleton_method(
526
+ "_upsample_bicubic2d",
527
+ *[](const Tensor &self, IntArrayRef output_size, bool align_corners) {
528
+ return torch::upsample_bicubic2d(self, output_size, align_corners);
529
+ })
530
+ .define_singleton_method(
531
+ "_upsample_bicubic2d_out",
532
+ *[](const Tensor &self, IntArrayRef output_size, bool align_corners, Tensor &out) {
533
+ return torch::upsample_bicubic2d_out(out, self, output_size, align_corners);
534
+ })
535
+ .define_singleton_method(
536
+ "_upsample_bilinear2d",
537
+ *[](const Tensor &self, IntArrayRef output_size, bool align_corners) {
538
+ return torch::upsample_bilinear2d(self, output_size, align_corners);
539
+ })
540
+ .define_singleton_method(
541
+ "_upsample_bilinear2d_out",
542
+ *[](const Tensor &self, IntArrayRef output_size, bool align_corners, Tensor &out) {
543
+ return torch::upsample_bilinear2d_out(out, self, output_size, align_corners);
544
+ })
545
+ .define_singleton_method(
546
+ "_upsample_linear1d",
547
+ *[](const Tensor &self, IntArrayRef output_size, bool align_corners) {
548
+ return torch::upsample_linear1d(self, output_size, align_corners);
549
+ })
550
+ .define_singleton_method(
551
+ "_upsample_linear1d_out",
552
+ *[](const Tensor &self, IntArrayRef output_size, bool align_corners, Tensor &out) {
553
+ return torch::upsample_linear1d_out(out, self, output_size, align_corners);
554
+ })
555
+ .define_singleton_method(
556
+ "_upsample_nearest1d",
557
+ *[](const Tensor &self, IntArrayRef output_size) {
558
+ return torch::upsample_nearest1d(self, output_size);
559
+ })
560
+ .define_singleton_method(
561
+ "_upsample_nearest1d_out",
562
+ *[](const Tensor &self, IntArrayRef output_size, Tensor &out) {
563
+ return torch::upsample_nearest1d_out(out, self, output_size);
564
+ })
565
+ .define_singleton_method(
566
+ "_upsample_nearest2d",
567
+ *[](const Tensor &self, IntArrayRef output_size) {
568
+ return torch::upsample_nearest2d(self, output_size);
569
+ })
570
+ .define_singleton_method(
571
+ "_upsample_nearest2d_out",
572
+ *[](const Tensor &self, IntArrayRef output_size, Tensor &out) {
573
+ return torch::upsample_nearest2d_out(out, self, output_size);
574
+ })
575
+ .define_singleton_method(
576
+ "_upsample_nearest3d",
577
+ *[](const Tensor &self, IntArrayRef output_size) {
578
+ return torch::upsample_nearest3d(self, output_size);
579
+ })
580
+ .define_singleton_method(
581
+ "_upsample_nearest3d_out",
582
+ *[](const Tensor &self, IntArrayRef output_size, Tensor &out) {
583
+ return torch::upsample_nearest3d_out(out, self, output_size);
584
+ })
585
+ .define_singleton_method(
586
+ "_upsample_trilinear3d",
587
+ *[](const Tensor &self, IntArrayRef output_size, bool align_corners) {
588
+ return torch::upsample_trilinear3d(self, output_size, align_corners);
589
+ })
590
+ .define_singleton_method(
591
+ "_upsample_trilinear3d_out",
592
+ *[](const Tensor &self, IntArrayRef output_size, bool align_corners, Tensor &out) {
593
+ return torch::upsample_trilinear3d_out(out, self, output_size, align_corners);
594
+ });
595
+ }