@@ -68,7 +68,7 @@ auto element_wise_registrations = RegisterNodeConversionPatterns()
68
68
TRTORCH_CHECK (add, " Unable to create add layer from node: " << *n);
69
69
70
70
add->setName (util::node_info (n).c_str ());
71
- auto out = associate_value_and_tensor ( ctx, n->outputs ()[0 ], add->getOutput (0 ));
71
+ auto out = ctx-> AssociateValueAndTensor ( n->outputs ()[0 ], add->getOutput (0 ));
72
72
73
73
LOG_DEBUG (" Output tensor shape: " << out->getDimensions ());
74
74
return true ;
@@ -85,7 +85,7 @@ auto element_wise_registrations = RegisterNodeConversionPatterns()
85
85
TRTORCH_CHECK (add, " Unable to create add layer from node: " << *n);
86
86
87
87
add->setName (util::node_info (n).c_str ());
88
- auto out = associate_value_and_tensor ( ctx, n->outputs ()[0 ], add->getOutput (0 ));
88
+ auto out = ctx-> AssociateValueAndTensor ( n->outputs ()[0 ], add->getOutput (0 ));
89
89
90
90
LOG_DEBUG (" Output tensor shape: " << out->getDimensions ());
91
91
return true ;
@@ -102,13 +102,13 @@ auto element_wise_registrations = RegisterNodeConversionPatterns()
102
102
TRTORCH_CHECK (sub, " Unable to create sub layer from node: " << *n);
103
103
104
104
sub->setName (util::node_info (n).c_str ());
105
- auto out = associate_value_and_tensor ( ctx, n->outputs ()[0 ], sub->getOutput (0 ));
105
+ auto out = ctx-> AssociateValueAndTensor ( n->outputs ()[0 ], sub->getOutput (0 ));
106
106
107
107
LOG_DEBUG (" Output tensor shape: " << out->getDimensions ());
108
108
return true ;
109
109
}
110
110
}).pattern({
111
- " aten::div(Tensor self, Tensor other) -> Tensor" ,
111
+ " aten::div.Tensor (Tensor self, Tensor other) -> Tensor" ,
112
112
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
113
113
// Should implement self / other
114
114
auto self = args[0 ].ITensor ();
@@ -118,13 +118,29 @@ auto element_wise_registrations = RegisterNodeConversionPatterns()
118
118
TRTORCH_CHECK (div, " Unable to create div layer from node: " << *n);
119
119
120
120
div->setName (util::node_info (n).c_str ());
121
- auto out = associate_value_and_tensor ( ctx, n->outputs ()[0 ], div->getOutput (0 ));
121
+ auto out = ctx-> AssociateValueAndTensor ( n->outputs ()[0 ], div->getOutput (0 ));
122
122
123
123
LOG_DEBUG (" Output tensor shape: " << out->getDimensions ());
124
124
return true ;
125
125
}
126
126
}).pattern({
127
- " aten::mul(Tensor self, Tensor other) -> Tensor" ,
127
+ " aten::div_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)" ,
128
+ [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
129
+ // TODO: Remove with functionalization
130
+ auto self = args[0 ].ITensor ();
131
+ auto other = args[1 ].ITensor ();
132
+ auto div = add_elementwise (ctx, nvinfer1::ElementWiseOperation::kDIV , self, other);
133
+
134
+ TRTORCH_CHECK (div, " Unable to create div layer from node: " << *n);
135
+
136
+ div->setName (util::node_info (n).c_str ());
137
+ auto out = ctx->AssociateValueAndTensor (n->outputs ()[0 ], div->getOutput (0 ));
138
+
139
+ LOG_DEBUG (" Output tensor shape: " << out->getDimensions ());
140
+ return true ;
141
+ }
142
+ }).pattern({
143
+ " aten::mul.Tensor(Tensor self, Tensor other) -> Tensor" ,
128
144
[](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
129
145
// Should implement self * other
130
146
auto self = args[0 ].ITensor ();
@@ -134,13 +150,65 @@ auto element_wise_registrations = RegisterNodeConversionPatterns()
134
150
TRTORCH_CHECK (mul, " Unable to create mul layer from node: " << *n);
135
151
136
152
mul->setName (util::node_info (n).c_str ());
137
- auto out = associate_value_and_tensor (ctx, n->outputs ()[0 ], mul->getOutput (0 ));
153
+ auto out = ctx->AssociateValueAndTensor (n->outputs ()[0 ], mul->getOutput (0 ));
154
+
155
+ LOG_DEBUG (" Output tensor shape: " << out->getDimensions ());
156
+ return true ;
157
+ }
158
+ }).pattern({
159
+ " aten::mul_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)" ,
160
+ [](ConversionCtx* ctx, const torch::jit::Node* n, args& args) -> bool {
161
+ // TODO: Remove with functionalization
162
+ auto self = args[0 ].ITensor ();
163
+ auto other = args[1 ].ITensor ();
164
+ auto mul = add_elementwise (ctx, nvinfer1::ElementWiseOperation::kPROD , self, other);
165
+
166
+ TRTORCH_CHECK (mul, " Unable to create mul layer from node: " << *n);
167
+
168
+ mul->setName (util::node_info (n).c_str ());
169
+ auto out = ctx->AssociateValueAndTensor (n->outputs ()[0 ], mul->getOutput (0 ));
138
170
139
171
LOG_DEBUG (" Output tensor shape: " << out->getDimensions ());
140
172
return true ;
141
173
}
142
174
});
143
175
176
+ // - func: div.Tensor(Tensor self, Tensor other) -> Tensor
177
+ // use_c10_dispatcher: full
178
+ // variants: function, method
179
+ // dispatch:
180
+ // CPU: div
181
+ // CUDA: div
182
+ // SparseCPU: div_sparse
183
+ // SparseCUDA: div_sparse
184
+ // supports_named_tensor: True
185
+
186
+ // - func: div_.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)
187
+ // variants: method
188
+ // dispatch:
189
+ // CPU: div_
190
+ // CUDA: div_
191
+ // SparseCPU: div_sparse_
192
+ // SparseCUDA: div_sparse_
193
+ // supports_named_tensor: True
194
+
195
+ // - func: div.out(Tensor self, Tensor other, *, Tensor(a!) out) -> Tensor(a!)
196
+ // dispatch:
197
+ // CPU: div_out
198
+ // CUDA: div_out
199
+ // SparseCPU: div_out_sparse_zerodim
200
+ // SparseCUDA: div_out_sparse_zerodim
201
+ // supports_named_tensor: True
202
+
203
+ // # For C++ only, until we have conversion from C++ numbers to Tensor
204
+ // - func: div.Scalar(Tensor self, Scalar other) -> Tensor
205
+ // use_c10_dispatcher: full
206
+ // variants: function, method
207
+ // supports_named_tensor: True
208
+
209
+ // - func: div_.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
210
+ // variants: method
211
+ // supports_named_tensor: True
144
212
145
213
} // namespace
146
214
} // namespace impl
0 commit comments