forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConvPlaceholders.cpp
179 lines (153 loc) · 7.72 KB
/
ConvPlaceholders.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#include <ATen/ATen.h>
#include <ATen/cuda/CUDAConfig.h> // for the definition of AT_CUDNN_ENABLED
#include <ATen/native/ConvUtils.h>
namespace at { namespace native {
// ---------------------------------------------------------------------
//
// Placeholder operators
//
// ---------------------------------------------------------------------
#if !AT_CUDNN_ENABLED()
// See Note [ATen preprocessor philosophy]
at::Tensor cudnn_convolution(
const at::Tensor& input, const at::Tensor& weight,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation,
int64_t groups, bool benchmark, bool deterministic, bool allow_tf32) {
AT_ERROR("cudnn_convolution: ATen not compiled with cuDNN support");
}
at::Tensor cudnn_convolution_backward_input(
IntArrayRef input_size, const at::Tensor& grad_output, const at::Tensor& weight,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups,
bool benchmark, bool deterministic, bool allow_tf32) {
AT_ERROR("cudnn_convolution_backward_input: ATen not compiled with cuDNN support");
}
at::Tensor cudnn_convolution_backward_weight(
IntArrayRef weight_size, const at::Tensor& grad_output, const at::Tensor& input,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups,
bool benchmark, bool deterministic, bool allow_tf32) {
AT_ERROR("cudnn_convolution_backward_weight: ATen not compiled with cuDNN support");
}
std::tuple<at::Tensor,at::Tensor> cudnn_convolution_backward(
const at::Tensor& input, const at::Tensor& grad_output, const at::Tensor& weight,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups,
bool benchmark, bool deterministic, bool allow_tf32, std::array<bool,2> output_mask) {
AT_ERROR("cudnn_convolution_backward: ATen not compiled with cuDNN support");
}
at::Tensor cudnn_convolution_transpose(
const at::Tensor& input, const at::Tensor& weight,
IntArrayRef padding, IntArrayRef output_padding, IntArrayRef stride, IntArrayRef dilation,
int64_t groups, bool benchmark, bool deterministic, bool allow_tf32) {
AT_ERROR("cudnn_convolution_transpose: ATen not compiled with cuDNN support");
}
at::Tensor cudnn_convolution_transpose_backward_input(
const at::Tensor& grad_output, const at::Tensor& weight,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation,
int64_t groups, bool benchmark, bool deterministic, bool allow_tf32) {
AT_ERROR("cudnn_convolution_transpose_backward: ATen not compiled with cuDNN support");
}
at::Tensor cudnn_convolution_transpose_backward_weight(
IntArrayRef weight_size, const at::Tensor& grad_output, const at::Tensor& input,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups,
bool benchmark, bool deterministic, bool allow_tf32) {
AT_ERROR("cudnn_convolution_transpose_backward_weight: ATen not compiled with cuDNN support");
}
std::tuple<at::Tensor,at::Tensor> cudnn_convolution_transpose_backward(
const at::Tensor& input, const at::Tensor& grad_output, const at::Tensor& weight,
IntArrayRef padding, IntArrayRef output_padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups,
bool benchmark, bool deterministic, bool allow_tf32, std::array<bool,2> output_mask) {
AT_ERROR("cudnn_convolution_transpose_backward: ATen not compiled with cuDNN support");
}
void raw_cudnn_convolution_forward_out(
const Tensor& output, const Tensor& input, const Tensor& weight,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups,
bool benchmark, bool deterministic, bool allow_tf32) {
AT_ERROR("raw_cudnn_convolution_forward_out: ATen not compiled with cuDNN support");
}
void raw_cudnn_convolution_backward_input_out(
const at::Tensor& grad_input,
const at::Tensor& grad_output,
const at::Tensor& weight,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups,
bool benchmark, bool deterministic, bool allow_tf32) {
AT_ERROR("raw_cudnn_convolution_backward_input_out: ATen not compiled with cuDNN support");
}
void raw_cudnn_convolution_backward_weight_out(
const Tensor& grad_weight, const Tensor& grad_output, const Tensor& input,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups,
bool benchmark, bool deterministic, bool allow_tf32) {
AT_ERROR("raw_cudnn_convolution_backward_weight_out: ATen not compiled with cuDNN support");
}
Tensor cudnn_convolution_relu(
const Tensor& input_t,
const Tensor& weight_t,
const c10::optional<Tensor>& bias_t,
IntArrayRef stride,
IntArrayRef padding,
IntArrayRef dilation,
int64_t groups) {
AT_ERROR("cudnn_convolution_relu: ATen not compiled with cuDNN support");
}
Tensor cudnn_convolution_add_relu(
const Tensor& input_t,
const Tensor& weight_t,
const Tensor& z_t,
const c10::optional<Scalar>& alpha,
const c10::optional<Tensor>& bias_t,
IntArrayRef stride,
IntArrayRef padding,
IntArrayRef dilation,
int64_t groups) {
AT_ERROR("cudnn_convolution_add_relu: ATen not compiled with cuDNN support");
}
#endif // AT_CUDNN_ENABLED
// ---------------------------------------------------------------------
//
// Deprecated operators
//
// ---------------------------------------------------------------------
// TODO (@zasdfgbnm): this is here only for compatibility, remove this in the future
Tensor cudnn_convolution_deprecated(
const Tensor& input, const Tensor& weight, const c10::optional<Tensor>& bias_opt /* optional */,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation,
int64_t groups, bool benchmark, bool deterministic) {
// See [Note: hacky wrapper removal for optional tensor]
c10::MaybeOwned<Tensor> bias_maybe_owned = at::borrow_from_optional_tensor(bias_opt);
const Tensor& bias = *bias_maybe_owned;
auto output = at::cudnn_convolution(input, weight, padding, stride, dilation, groups, benchmark, deterministic);
if (bias.defined()) {
output = output + reshape_bias(input.dim(), bias);
}
return output;
}
// TODO (@zasdfgbnm): this is here only for compatibility, remove this in the future
Tensor cudnn_convolution_deprecated2(
const Tensor& input_t, const Tensor& weight_t,
IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation,
int64_t groups, bool benchmark, bool deterministic)
{
return at::cudnn_convolution(input_t, weight_t, padding, stride, dilation, groups, benchmark, deterministic, at::globalContext().allowTF32CuDNN());
}
// TODO (@zasdfgbnm): this is here only for compatibility, remove this in the future
Tensor cudnn_convolution_transpose_deprecated(
const Tensor& input, const Tensor& weight, const c10::optional<Tensor>& bias_opt /* optional */,
IntArrayRef padding, IntArrayRef output_padding, IntArrayRef stride, IntArrayRef dilation,
int64_t groups, bool benchmark, bool deterministic)
{
// See [Note: hacky wrapper removal for optional tensor]
c10::MaybeOwned<Tensor> bias_maybe_owned = at::borrow_from_optional_tensor(bias_opt);
const Tensor& bias = *bias_maybe_owned;
auto output = at::cudnn_convolution_transpose(input, weight, padding, output_padding, stride, dilation, groups, benchmark, deterministic);
if (bias.defined()) {
output = output + reshape_bias(input.dim(), bias);
}
return output;
}
// TODO (@zasdfgbnm): this is here only for compatibility, remove this in the future
Tensor cudnn_convolution_transpose_deprecated2(
const Tensor& input_t, const Tensor& weight_t,
IntArrayRef padding, IntArrayRef output_padding, IntArrayRef stride, IntArrayRef dilation,
int64_t groups, bool benchmark, bool deterministic)
{
return at::cudnn_convolution_transpose(input_t, weight_t, padding, output_padding, stride, dilation, groups, benchmark, deterministic, at::globalContext().allowTF32CuDNN());
}
}}