Commits


yf711 authored and GitHub committed dc61d3b5b69
Fix symbolic shape inference script on precision loss issue (#15215) ### Description When calculating symbolic shape like `mul(get_int_val(values=[1024, 0.5]))`, the current script calls `get_int_val()` to get values, which values becomes `[1024, 0]`. Thus, the result of `mul(values)`->`mul([1024,0])`=0, but the expected shape size is 512 Fix: for math binary operations like `mul()` and `div()`, don't convert input shapes into integers if any possible precision loss happen; keep the input shape as float, finish the operation, and cast final result into integer and output the shape. Test cases are added: 1. mul(1024, 0.5)=>512 (before this fix, the output would be 0, as float 0.5 would be converted to int 0) 2. div(768, 1.5)=>512 (before this fix, the output would be 768, as float 1.5 would be converted to int 0) ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->