File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
python/tvm/relay/frontend Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,20 @@ def is_quantized_tensor(self, data):
254254 # Operator implementations
255255 def make_elemwise (self , name ):
256256 def elemwise (inputs , input_types ):
257+ if name == "divide" :
258+ # https://pytorch.org/docs/stable/generated/torch.div.html#torch.div
259+ # None - default behavior. Performs no rounding and, if both input and
260+ # other are integer types, promotes the inputs to the default scalar type.
261+ if all (["int" in input_type for input_type in input_types [:2 ]]):
262+ input_types [:2 ] = ["float32" ] * 2
263+ cast_inputs = []
264+ for inp in inputs [:2 ]:
265+ if np .isscalar (inp ):
266+ cast_inputs .append (_expr .const (inp , dtype = "float32" ))
267+ else :
268+ cast_inputs .append (_op .cast (inp , "float32" ))
269+ inputs [:2 ] = cast_inputs
270+
257271 data0 , data1 = self .pytorch_promote_types (inputs [:2 ], input_types [:2 ])
258272 return get_relay_op (name )(data0 , data1 )
259273
You can’t perform that action at this time.
0 commit comments