You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by Blacklong via Apache TVM Discuss <no...@discuss.tvm.ai> on 2020/09/11 09:14:59 UTC

[Apache TVM Discuss] [Questions] Prelu op can not support broadcast?


Hi,all,I have some problem about ONNX Prelu.I convert my pytorch model to onnx ,but got error:

    In `main`: 
    #[version = "0.0.5"]
    fn (%inputL: Tensor[(1, 3, 512, 960), float32], %feature_extraction.firstconv.conv1.0.0.weight: Tensor[(48, 3, 1, 1), float32], %feature_extraction.firstconv.conv1.0.1.weight: Tensor[(48), float32], %feature_extraction.firstconv.conv1.0.1.bias: Tensor[(48), float32], %feature_extraction.firstconv.conv1.0.1.running_mean: Tensor[(48), float32], %feature_extraction.firstconv.conv1.0.1.running_var: Tensor[(48), float32], %v1552: Tensor[(1, 1, 1), float32]) {
      %0 = nn.conv2d(%inputL, %feature_extraction.firstconv.conv1.0.0.weight, padding=[0, 0, 0, 0], kernel_size=[1, 1]);
      %1 = nn.batch_norm(%0, %feature_extraction.firstconv.conv1.0.1.weight, %feature_extraction.firstconv.conv1.0.1.bias, %feature_extraction.firstconv.conv1.0.1.running_mean, %feature_extraction.firstconv.conv1.0.1.running_var);
      %2 = %1.0;
      %3 = reshape(%v1552, newshape=[-1]);
      nn.prelu(%2, %3) in particular dimension 0 conflicts 48 does not match 1; unable to unify: Tensor[(48), float32]` and `Tensor[(1), float32]`;
 I have read the doc about prelu:

> ### **PRelu**
> 
> PRelu takes input data (Tensor) and slope tensor as input, and produces one output data (Tensor) where the function  `f(x) = slope * x for x < 0` ,  `f(x) = x for x >= 0` ., is applied to the data tensor elementwise. This operator supports  **unidirectional broadcasting**  (tensor slope should be unidirectional broadcastable to input tensor X); for more details please check [the doc](https://github.com/onnx/onnx/blob/master/docs/Broadcasting.md).
> 
> #### Version
> 
> This version of the operator has been available since version 9 of the default ONNX operator set.
> 
> Other versions of this operator: [1](https://github.com/onnx/onnx/blob/master/docs/Changelog.md#PRelu-1), [6](https://github.com/onnx/onnx/blob/master/docs/Changelog.md#PRelu-6), [7](https://github.com/onnx/onnx/blob/master/docs/Changelog.md#PRelu-7)
> 
> #### Inputs
> 
> X : T
> 
> Input tensor
> 
> slope : T
> 
> Slope tensor. The shape of slope can be smaller then first input X; if so, its shape must be unidirectional broadcastable to X
> 
> #### Outputs
> 
> Y : T
> 
> Output tensor (same size as X)

my model have the prelu op,the slope shape is (1,1,1)
the Input tensor shape is (1,48,512,960)
Maybe tvm prelu can not support broadcast?

Thanks!





---
[Visit Topic](https://discuss.tvm.apache.org/t/prelu-op-can-not-support-broadcast/7880/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/422b0b2317f6c5c8f229909f87b5a6b19095559f8605fd92ba508096468be232).

[Apache TVM Discuss] [Questions] Prelu op can not support broadcast?

Posted by tqchen via Apache TVM Discuss <no...@discuss.tvm.ai>.

cc @jwfromm @masahi can you help confirm?





---
[Visit Topic](https://discuss.tvm.apache.org/t/prelu-op-can-not-support-broadcast/7880/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/efbe3999f7468953a18d5b615738a33c80c5e2acfa76c6b1b9842f77e0499c7f).

[Apache TVM Discuss] [Questions] Prelu op can not support broadcast?

Posted by Josh Fromm via Apache TVM Discuss <no...@discuss.tvm.ai>.

Sorry for the delay in response. @blacklong617, you're right that we should support broadcasting alpha but currently dont. This PR: https://github.com/apache/incubator-tvm/pull/6549 fixes the issue.





---
[Visit Topic](https://discuss.tvm.apache.org/t/prelu-op-can-not-support-broadcast/7880/3) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/95fe3afa5273b3cc7b02450ec88a60bf86b217053c72a3aa1d2400cecfc6c200).

[Apache TVM Discuss] [Questions] Prelu op can not support broadcast?

Posted by Blacklong via Apache TVM Discuss <no...@discuss.tvm.ai>.

@jwfromm Thanks very much, I will update and have a try.





---
[Visit Topic](https://discuss.tvm.apache.org/t/prelu-op-can-not-support-broadcast/7880/5) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/911abc26f1601440b2027f453d81877057a82eb8604f6de47d670334c26104b6).

[Apache TVM Discuss] [Questions] Prelu op can not support broadcast?

Posted by Josh Fromm via Apache TVM Discuss <no...@discuss.tvm.ai>.

The fix is now merged, if you update to master your model should work.





---
[Visit Topic](https://discuss.tvm.apache.org/t/prelu-op-can-not-support-broadcast/7880/4) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/e8a9712067338f49d54d7b8501d96f012f98846b621b64b8f91520382a536767).