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 ckh via TVM Discuss <no...@discuss.tvm.ai> on 2020/04/01 05:30:17 UTC

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow


Hello!

Currently, I am testing to compare the performance of direct conv2d and winograd conv2d using TOPI.
However, as a result of experiments, conv2d using winograd algorithm is too much worse than direct.
The code below is the code I experimented with.

    ## data shape
    data_shape = (1,3,224,224)
    w_shape = (64,3,3,3)

    ## Data
    sample_data = np.random.uniform(-1,1, size=data_shape ).astype("float32")
    sample_p1 = np.random.uniform(-1,1, size=w_shape ).astype("float32")

    ## placeholder
    input_data = tvm.te.placeholder( shape = data_shape, dtype = "float32", name="Input" )
    p1 = tvm.te.placeholder( shape = w_shape, dtype="float32", name="p1" )

    ## Winograd conv2d
    with tvm.target.create('cuda'):
        conv = topi.cuda.conv2d_nchw_winograd(input_data
                                              ,p1 
                                              ,(1,1)
                                              ,(0,0)
                                              ,(1,1)
                                              ,"float32"  )
        sch = topi.cuda.schedule_conv2d_nchw_winograd([conv])
        winoMod = tvm.build( sch, [ input_data,p1,conv] , target, name='wino')

    ## Direct conv2d
    with tvm.target.create('cuda'):
        conv = topi.cuda.conv2d_nchw( input_data
                                        ,p1 
                                        ,[1,1]
                                        ,[0,0]
                                        ,[1,1] )
        sch = topi.cuda.schedule_conv2d_nchw([conv])
        simpleMod = tvm.build(sch, [input_data,p1], target, name='direct' )


    ## Real data
    tvm_input = tvm.nd.array( sample_data , ctx )
    tvm_p1 = tvm.nd.array( sample_p1, ctx )

    ## Performance Testing
    ev_wino = winoMod.time_evaluator(winoMod.entry_name, ctx, number=1,repeat=100 )
    ev_conv = simpleMod.time_evaluator(simpleMod.entry_name, ctx, number=1,repeat=100 )

    timer = ev_conv( tvm_input, tvm_p1).mean*1e3
    print("Conv with Direct algo -> ",timer)
    timer = ev_wino( tvm_input, tvm_p1).mean*1e3
    print("Conv with Winograd Strassen algo -> ",timer )

The execution result is as follows.

    Conv with Direct algo ->  0.11522044
    Conv with Winograd Strassen algo ->  4.70840109

The performance gap is too big.
According to the [Fast Algorithms for Convolutional Neural Networks paper](https://arxiv.org/abs/1509.09308), I think performance is higher or similar than direct conv2d.
Is there something I misunderstood?





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/89a1a4bd70f6ab8207a7ba366d2beb7929ccd1ba5069e5aec67802cfe4ef4dc4).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

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

i conducted additional experiments.

When using  Conv 1.2 layer of VGG-16 network, according to the [paper](https://arxiv.org/abs/1509.09308), performance should be better than direct conv2d.

But the result is that direct conv2d is better.

    input_img shape = (1,64,224,224)  ## NCHW Format
    weight shape = (64,64,3,3)
    bias shape = (64,)
    Conv with Direct algo ->  0.563ms
    Conv with Winograd Strassen algo ->  22.261ms

The winograd performance is too low than direct conv2d.
is it normal?





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/4) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/e2c8bfe327c571f155bda42ea36c21d35450594923f8c65bee3b318c22f9dd8d).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

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

i try bigger channel img and weight like below.

`img_shape = ( 1,512,224,224 ) , w_shape = (256,512,3,3 )`

shape format is a NCHW.

and the result is 

    direct => 50.641ms
    winograd => 604.84ms

the performance not good than direct conv2d...
Should I use more channels?





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/3) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/8f2197a634ac360c9524e4c3f00ec17a6d80ced96eb1052241d6c38e6076f383).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

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

try bigger number of channels. Winograd is slow for small channels.





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/f42e8f6e142a648a999751f2677f4a2e45391e488d85df60694e7937b809cea8).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

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

Thanks for the advice. haichen!

I think i should try optimizing winograd using autotvm.
Thank you.





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/8) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/78920df44fc7fa3b701ef7f4f38b3f6a08f591e1aebc05089c0b474b35cb39e4).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

Posted by Haichen Shen via TVM Discuss <no...@discuss.tvm.ai>.

I didn't compare these two implementation using fallback config before. But based on your observation, I think it's the case that winograd fallback config does perform poorly.





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/7) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/aca3b95ad3f40af9d2c1ca419c0f26faf42e2ebdfe8a96a6ddc7bd8913057ccc).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

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

thank you for the reply haichen! i will try it.

I'm curious that the two convolutions are using fallback configuration not tunned by autoTVM.
However, winograd is slow, with almost 200 times the performance difference. In general, does winograd perform poorly before tunning?





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/6) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/efe344acb64e134942fcb09c9ea11dc1ff4562c69dc8448d375d36594441834d).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

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

Thank you for your reply.

[quote="haichen, post:10, topic:6161"]
The strategy to select implementations for `conv2d` op is defined at [here ](https://github.com/apache/incubator-tvm/blob/master/python/tvm/relay/op/strategy/cuda.py#L91-L198)
[/quote]
Which function in AutoTVM will use this strategy?

[quote="puddingfjz, post:9, topic:6161"]
Also, are there any examples or tutorials on how to use these templates?
[/quote]
I want to ask how to use one template which is implemented by TVM to autotune an operator, and someone already helped me on this, but I [still have a question](https://discuss.tvm.ai/t/how-to-use-autotvm-with-manually-created-topi-computations/4895/12?u=puddingfjz), and maybe you can help.

[quote="puddingfjz, post:9, topic:6161"]
are there templates with more kinds of knobs?
[/quote]
By reading the documents and some code, I find that there are four functions which can define the ```config_space```: ```define_split, define_reorder, define_annotate, define_knob```. I also find that ```define_split, define_knob``` are the most used. Is it because ```loop tiling``` and ```loop unrolling``` is the most important or comman techniques to automatically optimize an operator? 

Thank you in advance.





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/11) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/6ba5dd9ab417e09fc7837f247c659c135b9a55101039f68abfa4632839fcd40c).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

Posted by Haichen Shen via TVM Discuss <no...@discuss.tvm.ai>.

The implementations for CUDA are defined in `topi/python/topi/cuda`. The strategy to select implementations for `conv2d` op is defined at [here](https://github.com/apache/incubator-tvm/blob/master/python/tvm/relay/op/strategy/cuda.py#L91-L198).

I don't understand your second question very well. Do you want to know how to write an AutoTVM template?





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/10) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/8df86f163eea0337918fa892abd0ccfb0e06c7a3c547bd49385e6246365eb220).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

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

Hi, I am now trying to use AutoTVM to tune the templates for different operators, but I do not know where exactly those templates which are already implemented by tvm are. Could you help me on this? Also, are there any examples or tutorials on how to use these templates?

And from the Tuning High Performance Convolution on NVIDIA GPUs tutorial, I find that the search space is defined with tile knobs and unrolling knobs, are there templates with more kinds of knobs?

Thank you in advance.





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/9) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/bdc515f031a2c4d4ff7e7835dceb0567c124131395768549449c0e831edf2ef3).

[TVM Discuss] [Questions] [ TOPI ] Winograd convolution performance is too slow

Posted by Haichen Shen via TVM Discuss <no...@discuss.tvm.ai>.

Have you used AutoTVM to tune the winograd template? The default schedule could be slow.





---
[Visit Topic](https://discuss.tvm.ai/t/topi-winograd-convolution-performance-is-too-slow/6161/5) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/77c0971509bc290b5ccc782808389b8b2f8124845f7ed4b9f12bb9a1c4712139).