File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,28 @@ def free_tpl(self):
266
266
register (Add , torch .autograd ._functions .basic_ops .Add )
267
267
268
268
269
+ class AddConstant (Emitter ):
270
+
271
+ def __init__ (self , obj , prevfns ):
272
+ Emitter .__init__ (self , obj , prevfns )
273
+ print (obj .constant )
274
+ self .def_vars ({'input' : id (prevfns [0 ])})
275
+ self .infer_type_var = 'input'
276
+ self .def_args ({'constant' : obj .constant })
277
+
278
+ def call_tpl (self ):
279
+ return '''
280
+ TH${T}Tensor *$id = TH${T}Tensor_new();
281
+ TH${T}Tensor_add($id,$input,$constant);
282
+ '''
283
+
284
+ def free_tpl (self ):
285
+ return '''
286
+ TH${T}Tensor_free($id);
287
+ '''
288
+
289
+ register (AddConstant , torch .autograd ._functions .basic_ops .AddConstant )
290
+
269
291
270
292
271
293
class Softmax (Emitter ):
You can’t perform that action at this time.
0 commit comments