You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/01/12 02:58:29 UTC

[GitHub] [tvm] alnah005 opened a new issue #9908: QLinearMatMul works with binary output only [Bug]

alnah005 opened a new issue #9908:
URL: https://github.com/apache/tvm/issues/9908


   I'm using [`from_onnx`](https://github.com/apache/tvm/blob/44fe7ef816565f43380c50e0b43fd626fad9d029/python/tvm/relay/frontend/onnx.py#L5063) to convert my model 
   [dense_h32_w32_c3_sNone_pNone_kNone.pt_quant.onnx.zip](https://github.com/apache/tvm/files/7851265/dense_h32_w32_c3_sNone_pNone_kNone.pt_quant.onnx.zip) into tvm relay. It looks like `b_scale` in [`QLinearMatMul`](https://github.com/apache/tvm/blob/44fe7ef816565f43380c50e0b43fd626fad9d029/python/tvm/relay/frontend/onnx.py#L3760) expects a scalar scale not a vector of scales. 
   I'm not sure if this is a problem with onnx creating a vector for the weights, or if QLinearMatMul should support scale vectors.
   
   Info about the model:
   1. Input: (batch, channel, height, width) -> (1, 3, 32, 32)
   2. Global Average pool: (batch, channel, 1, 1) -> (1, 3, 1, 1)
   3. Reshape: (batch, channel) -> (1, 3)
   4. Dense Layer: (batch, channel, 20) -> (3, 20) 
       > Dense Layer is where the error occurs 
   
   > You might notice when you debug `b_scale`'s shape that it's has shape=20. 
   
   ### Expected behavior
   
   No errors converting my model [dense_h32_w32_c3_sNone_pNone_kNone.pt_quant.onnx.zip](https://github.com/apache/tvm/files/7851265/dense_h32_w32_c3_sNone_pNone_kNone.pt_quant.onnx.zip) into tvm relay using  [`from_onnx`](https://github.com/apache/tvm/blob/44fe7ef816565f43380c50e0b43fd626fad9d029/python/tvm/relay/frontend/onnx.py#L5063).
   
   
   ### Actual behavior
   
   ```
   assert num_elem == 1, "Cannot squeeze tensor shape {} to scalar form.".format(x_shape)
   E       AssertionError: Cannot squeeze tensor shape (20,) to scalar form.
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] cconvey commented on issue #9908: [Bug] [ONNX] QLinearMatMul works with binary output only

Posted by GitBox <gi...@apache.org>.
cconvey commented on issue #9908:
URL: https://github.com/apache/tvm/issues/9908#issuecomment-1011444121


   Thanks @alnah005 @FZYUAN-1 for creating this Issue and pinging me!
   
   As far as I can tell, the input model is valid ONNX, and you're bumping into a limitation in the current version of the ONNX->TVM importer code.
   
   I'm afraid I don't have the bandwidth to (personally) fix this a the moment, but if someone else wants to create a PR I'd be very happy to review it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] masahi closed issue #9908: [Bug] [ONNX] QLinearMatMul works with binary output only

Posted by GitBox <gi...@apache.org>.
masahi closed issue #9908:
URL: https://github.com/apache/tvm/issues/9908


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] FZYUAN-1 commented on issue #9908: [Bug] [ONNX] QLinearMatMul works with binary output only

Posted by GitBox <gi...@apache.org>.
FZYUAN-1 commented on issue #9908:
URL: https://github.com/apache/tvm/issues/9908#issuecomment-1011454560


   
   > Thanks @alnah005 @FZYUAN-1 for creating this Issue and pinging me!
   > 
   > As far as I can tell, the input model is valid ONNX, and you're bumping into a limitation in the current version of the ONNX->TVM importer code.
   > 
   > I'm afraid I don't have the bandwidth to (personally) fix this a the moment, but if someone else wants to create a PR I'd be very happy to review it.
   
   Thanks for your reply!
   I will fix this in next several days. @alnah005 @denise-k 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] alnah005 commented on issue #9908: QLinearMatMul works with binary output only [Bug]

Posted by GitBox <gi...@apache.org>.
alnah005 commented on issue #9908:
URL: https://github.com/apache/tvm/issues/9908#issuecomment-1010606856


   Code to reproduce:
   ```
   import onnx
   from tvm import relay
   m = onnx.load("dense_h32_w32_c3_sNone_pNone_kNone.pt_quant.onnx")
   relay.frontend.from_onnx(m)
   ```
   Error:
   ```
   AssertionError: Cannot squeeze tensor shape (20,) to scalar form.
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] FZYUAN-1 commented on issue #9908: [Bug] [ONNX] QLinearMatMul works with binary output only

Posted by GitBox <gi...@apache.org>.
FZYUAN-1 commented on issue #9908:
URL: https://github.com/apache/tvm/issues/9908#issuecomment-1011380854


   Hello,
   @cconvey The current implementation of QLinearMatMul in TVM may not support scale vectors. The behaviour for now is parsing the input scale as scalar. See PR https://github.com/apache/tvm/pull/8952. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org