@@ -332,6 +332,50 @@ def free_tpl(self):
332
332
register (SubConstant , torch .autograd ._functions .basic_ops .SubConstant )
333
333
334
334
335
+ class Mul (Emitter ):
336
+
337
+ def __init__ (self , obj , prevfns ):
338
+ Emitter .__init__ (self , obj , prevfns )
339
+ self .def_vars ({'input0' : id (prevfns [0 ]),
340
+ 'input1' : id (prevfns [1 ])})
341
+ self .infer_type_var = 'input0'
342
+
343
+ def call_tpl (self ):
344
+ return '''
345
+ TH${T}Tensor *$id = TH${T}Tensor_new();
346
+ TH${T}Tensor_cmul($id,$input0,$input1);
347
+ '''
348
+
349
+ def free_tpl (self ):
350
+ return '''
351
+ TH${T}Tensor_free($id);
352
+ '''
353
+
354
+ register (Mul , torch .autograd ._functions .basic_ops .Mul )
355
+
356
+
357
+ class MulConstant (Emitter ):
358
+
359
+ def __init__ (self , obj , prevfns ):
360
+ Emitter .__init__ (self , obj , prevfns )
361
+ self .def_vars ({'input' : id (prevfns [0 ])})
362
+ self .infer_type_var = 'input'
363
+ self .def_args ({'constant' : obj .constant })
364
+
365
+ def call_tpl (self ):
366
+ return '''
367
+ TH${T}Tensor *$id = TH${T}Tensor_new();
368
+ TH${T}Tensor_mul($id,$input,$constant);
369
+ '''
370
+
371
+ def free_tpl (self ):
372
+ return '''
373
+ TH${T}Tensor_free($id);
374
+ '''
375
+
376
+ register (MulConstant , torch .autograd ._functions .basic_ops .MulConstant )
377
+
378
+
335
379
class Softmax (Emitter ):
336
380
337
381
def __init__ (self , obj , prevfns ):
0 commit comments