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 2021/09/08 03:58:28 UTC

[GitHub] [tvm] csullivan opened a new pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

csullivan opened a new pull request #8960:
URL: https://github.com/apache/tvm/pull/8960


   This PR adds llvm unit tests that demonstrate the scheduling of conv2d and maxpool2d using a blocked packed layout wherein spatial and channel dimensions are split into blocks. These tests can serve as a base off which to develop lowering for hexagon.


-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704782084



##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):

Review comment:
       This is for filters with logical shape: OIHW, where O = out_channels, I = in_channels, and H and W are the kernel dimensions. `oihw8i32o4i` can be read as [O//32, I//32, H, W, 8i, 32o, 4i], where the out_channel dim is split into two axes (O//32, and 32o), and the in_channel dim is split into three axes [I//32, 8i, 4i]. 




-- 
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] tmoreau89 commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
tmoreau89 commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704783647



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,

Review comment:
       comment: we haven't been using KCRS convention more commonly used by Nvidia etc. but instead have been using the OIHW notation for better or worse. Doing a quick search for the use of KCRS pointed me to your texture codegen work :) 




-- 
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] adstraw commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
adstraw commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704845672



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,
+    kernel_size,
+    stride,
+    padding,
+    dtype,
+    storage_scope="global",
+):
+    """
+    Conv2d TE wherein both input activation and filter tensors
+    are defined with their logical NHWC/OIHW shapes, respectively.
+    The packed physical layout for the activation and filter are:
+      Activation: nhwc8h8w32c
+      Filter: oihw8i32o4i
+    """
+    assert kernel_size == tuple(shape_kcrs[2:])
+
+    block_shape = 8, 8, 32

Review comment:
       Might be better to add a function e.g. `get_block_shape` here even if we don't think we will ever change these numbers.  Much easier to change / generalize later if needed.

##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):
+    out_factor, in_factor, in_second_factor = 32, 32, 4
+    return (
+        int(ceildiv(out_channel, out_factor)),
+        int(ceildiv(in_channel, in_factor)),
+        kernel,
+        kernel,
+        in_factor // in_second_factor,

Review comment:
       in_first_factor

##########
File path: tests/python/contrib/test_hexagon/infrastructure.py
##########
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing infrastructure """
+
+import tvm
+import numpy
+
+
+def ceildiv(o, d):
+    return tvm.tir.floordiv(o + d - 1, d)
+
+
+def get_packed_layout(logical_shape_nhwc, block_shape, packed_C=True):
+    shape = [logical_shape_nhwc[0]]
+    off_h, off_w, off_c = block_shape
+    shape.append(ceildiv(logical_shape_nhwc[1], off_h))
+    shape.append(ceildiv(logical_shape_nhwc[2], off_w))
+    if packed_C:
+        shape.append(ceildiv(logical_shape_nhwc[3], off_c))
+        shape.extend(block_shape)
+    else:
+        shape.extend([off_h, off_w, logical_shape_nhwc[-1]])

Review comment:
       Wondering why `-1` was used here instead of `3`.  Concerned about the size of `logical_shape_nhwc` being != 4?  Should this be an assert?

##########
File path: tests/python/contrib/test_hexagon/infrastructure.py
##########
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing infrastructure """
+
+import tvm
+import numpy
+
+
+def ceildiv(o, d):
+    return tvm.tir.floordiv(o + d - 1, d)
+
+
+def get_packed_layout(logical_shape_nhwc, block_shape, packed_C=True):
+    shape = [logical_shape_nhwc[0]]
+    off_h, off_w, off_c = block_shape
+    shape.append(ceildiv(logical_shape_nhwc[1], off_h))
+    shape.append(ceildiv(logical_shape_nhwc[2], off_w))
+    if packed_C:
+        shape.append(ceildiv(logical_shape_nhwc[3], off_c))
+        shape.extend(block_shape)
+    else:
+        shape.extend([off_h, off_w, logical_shape_nhwc[-1]])
+    return shape
+
+
+def build_and_run(inputs, func, target, target_host, *args, **kwargs):
+    s, placeholders, binds = func(*args, **kwargs)

Review comment:
       `s` is for schedule right?  I would prefer a more verbose name here but perhaps that's because I am not used to this naming convention.

##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,

Review comment:
       I agree with @csullivan that KCRS is better from a code perspective and avoids name conflicts.  However, OIHW is used throughout this PR and the linkage that KCRS == OIHW is not exceedingly clear.  Perhaps that could be made more explicit?

##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,
+    kernel_size,
+    stride,
+    padding,
+    dtype,
+    storage_scope="global",
+):
+    """
+    Conv2d TE wherein both input activation and filter tensors
+    are defined with their logical NHWC/OIHW shapes, respectively.
+    The packed physical layout for the activation and filter are:
+      Activation: nhwc8h8w32c
+      Filter: oihw8i32o4i
+    """
+    assert kernel_size == tuple(shape_kcrs[2:])
+
+    block_shape = 8, 8, 32
+    block_H, block_W, block_C = block_shape
+    shape = get_packed_layout(shape_nhwc, block_shape)
+    logical_output_shape = (

Review comment:
       General comment (or perhaps a question) : I am a little surprised that this sort of shape calculation is explicitly stated here.  This seems to be a pretty general "what is the logical shape of my convolution?" computation.  Should this not be in library code somewhere?  Perhaps this is by convention?  Comment / question applies to other shape / pad / etc. calculations below, I think.

##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):
+    out_factor, in_factor, in_second_factor = 32, 32, 4

Review comment:
       I think it would be more clear match the order and numbers in the layout (8, 32, 4) with the factors as follows:
   
   ```
   in_first_factor, out_factor, in_second_factor = 8, 32, 4
   in_factor = in_first_factor * in_second_factor
   ```
   




-- 
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] tmoreau89 commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
tmoreau89 commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704784633



##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):

Review comment:
       Aha, so in this case `in_factor = in_first_factor * in_second_factor`. Got it, thank you. 




-- 
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] tmoreau89 merged pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
tmoreau89 merged pull request #8960:
URL: https://github.com/apache/tvm/pull/8960


   


-- 
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] areusch commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r709528557



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,473 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import (
+    ceildiv,
+    build_and_run,
+    get_block_shape,
+    get_conv2d_nhwc_shape,
+    get_packed_filter_layout,
+    get_packed_activation_layout,
+)
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_oihw,
+    kernel_size,
+    stride,
+    padding,
+    dtype,
+    storage_scope="global",
+):
+    """
+    Conv2d TE wherein both input activation and filter tensors
+    are defined with their logical NHWC/OIHW shapes, respectively.
+    The packed physical layout for the activation and filter are:
+      Activation: nhwc8h8w32c
+      Filter: oihw8i32o4i
+    """
+    assert kernel_size == tuple(shape_oihw[2:])
+
+    block_shape = get_block_shape()
+    block_H, block_W, block_C = block_shape
+    shape = get_packed_activation_layout(shape_nhwc, block_shape)
+    logical_output_shape = get_conv2d_nhwc_shape(
+        shape_nhwc, kernel_size, stride, padding, [1, 1], shape_oihw[0]
+    )
+    output_shape = get_packed_activation_layout(logical_output_shape, block_shape)
+
+    N, H, W, C = shape_nhwc
+    X = te.placeholder(shape_nhwc, dtype=dtype)
+    # Combination of padding required by conv2d operator and padding to evenly divisible
+    # number of blocks. Note that this padding should be inlined in the schedule so
+    # as to avoid input copying.
+    pad_h = (block_H - ((H + padding[1]) % block_H)) % block_H

Review comment:
       is the second `% block_H` necessary?




-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r705793778



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,

Review comment:
       Good suggestion, I updated the API as you suggested!




-- 
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] adstraw commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
adstraw commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704855929



##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):
+    out_factor, in_factor, in_second_factor = 32, 32, 4

Review comment:
       [Moving my comment out of Thierry's resolved thread.]  I think it would be more clear match the order and numbers in the layout (8, 32, 4) with the factors as follows:
   ```
   in_first_factor, out_factor, in_second_factor = 8, 32, 4
   in_factor = in_first_factor * in_second_factor
   ```




-- 
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] csullivan commented on pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#issuecomment-915375518


   cc @kparzysz-quic @Lunderberg @tmoreau89 


-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r705795133



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,
+    kernel_size,
+    stride,
+    padding,
+    dtype,
+    storage_scope="global",
+):
+    """
+    Conv2d TE wherein both input activation and filter tensors
+    are defined with their logical NHWC/OIHW shapes, respectively.
+    The packed physical layout for the activation and filter are:
+      Activation: nhwc8h8w32c
+      Filter: oihw8i32o4i
+    """
+    assert kernel_size == tuple(shape_kcrs[2:])
+
+    block_shape = 8, 8, 32
+    block_H, block_W, block_C = block_shape
+    shape = get_packed_layout(shape_nhwc, block_shape)
+    logical_output_shape = (

Review comment:
       In general the shape is usually calculated near the compute definition because it provides the bounds on the induction variables given that the layouts can often change, which affects the shape calculation. 
   
   That said, thank you for this CR! I decided to at least factor it into a helper in the infrastructure module and in the process I discovered a couple of bugs in the shape calculation.




-- 
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] tmoreau89 commented on pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
tmoreau89 commented on pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#issuecomment-919523036


   Thank you @adstraw @Lunderberg @csullivan the PR has been merged
   


-- 
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] Lunderberg commented on pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
Lunderberg commented on pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#issuecomment-916091088


   The changes look good to me.  I like the hoisting of the shape definitions up into the `conftest.py`, to avoid redefinition across multiple files.


-- 
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] tmoreau89 commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
tmoreau89 commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704774420



##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):
+    out_factor, in_factor, in_second_factor = 32, 32, 4
+    return (
+        int(ceildiv(out_channel, out_factor)),

Review comment:
       This assumes we return a padded shape, correct?




-- 
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] csullivan commented on pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#issuecomment-916516137


   Thanks for the feedback @tmoreau89 @adstraw @Lunderberg, I've updated the commit. Please take a look when you have a chance.


-- 
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] tmoreau89 commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
tmoreau89 commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704772725



##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):

Review comment:
       trying to parse this out: 8i 32o 4i
   Meaning in factor is 8, out factor is 32 and second/inner in factor is 4. Am I reading this right?




-- 
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] tmoreau89 commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
tmoreau89 commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704773227



##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):
+    out_factor, in_factor, in_second_factor = 32, 32, 4

Review comment:
       According to the above comment, should these be 32, 8, 4?




-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704840247



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,

Review comment:
       If you would like I can convert the conv2d definitions over to OIHW for consistency. I actually did in anticipation of someone making this comment, but I reverted it because I became confused when reading the schedule. :) Too many axes like `Oi`, `Ii`, `Iii`, `H_input`, `H_filter`, `W_inp`, `W_filt` floating around. That said, I don't have strong feelings on it either way.




-- 
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] tmoreau89 commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
tmoreau89 commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r705516793



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,

Review comment:
       Good point on the notation being less ambiguous. I'd recommend using OIHW notation for API (function names and argument names) but for axes, I think the KCRS is nice because it avoids the ambiguity on W and H etc.




-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704784838



##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):
+    out_factor, in_factor, in_second_factor = 32, 32, 4

Review comment:
       These are the factors, not the dimension extents if that helps. 32 input channels are factored out and then those 32 input channels are factored again by a factor of 4 in order to interleave them with the 32 output channels in a 8i32o4i pattern.




-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r705793968



##########
File path: tests/python/contrib/test_hexagon/infrastructure.py
##########
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing infrastructure """
+
+import tvm
+import numpy
+
+
+def ceildiv(o, d):
+    return tvm.tir.floordiv(o + d - 1, d)
+
+
+def get_packed_layout(logical_shape_nhwc, block_shape, packed_C=True):
+    shape = [logical_shape_nhwc[0]]
+    off_h, off_w, off_c = block_shape
+    shape.append(ceildiv(logical_shape_nhwc[1], off_h))
+    shape.append(ceildiv(logical_shape_nhwc[2], off_w))
+    if packed_C:
+        shape.append(ceildiv(logical_shape_nhwc[3], off_c))
+        shape.extend(block_shape)
+    else:
+        shape.extend([off_h, off_w, logical_shape_nhwc[-1]])

Review comment:
       Good call, changed and added an assert.




-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704840247



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,

Review comment:
       I can convert the conv2d definitions over to OIHW for consistency. I actually did in anticipation of someone making this comment, but I reverted it because I became confused when reading the schedule. :) Too many axes like `Oi`, `Ii`, `Iii`, `H_input`, `H_filter`, `W_inp`, `W_filt` floating around. That said, I don't have strong feelings on it either way.




-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704788937



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,

Review comment:
       Yeah, I prefer KCRS when doing conv2d because it makes it clear that the C in the filter is the same C in the input activation, and the K is the same K in the output activation. It also disambiguates the HW in the input (NHWC) and the filter (OIHW) by instead using R and S. When the filter shape is discussed in isolation, it's okay to use OIHW, but when writing out compute definitions for convolution, nhwc and oihw together become really messy in my opinion. 




-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704788937



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,

Review comment:
       Yeah, I prefer KCRS when doing conv2d because it makes it clear that the C in the filter is the same C in the input activation, and the K is the same K in the output activation (NHWK). It also disambiguates the HW in the input (NHWC) and the filter (OIHW) by instead using R and S. When the filter shape is discussed in isolation, it's okay to use OIHW, but when writing out compute definitions for convolution, nhwc and oihw together become really messy in my opinion. 




-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704788937



##########
File path: tests/python/contrib/test_hexagon/test_conv2d_blocked.py
##########
@@ -0,0 +1,474 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import sys
+
+import tvm
+from tvm import te
+from tvm import topi
+from tvm.topi import testing
+from .infrastructure import ceildiv
+from .infrastructure import get_packed_layout
+from .infrastructure import build_and_run
+
+import numpy as np
+import pytest
+
+
+def conv2d_logical(
+    shape_nhwc,
+    shape_kcrs,

Review comment:
       Yeah, I prefer KCRS when doing conv2d because it makes it clear that the C in the filter is the same C in the input activation, and the K is the same K in the output activation. It also disambiguates the HW in the input (NHWC) and the filter (OIHW) by instead using R and S for the filter size. When the filter shape is discussed in isolation it's okay to use OIHW, but when writing out compute definitions for convolution, nhwc and oihw together become really messy in my opinion. 




-- 
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] tmoreau89 commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
tmoreau89 commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704785293



##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):
+    out_factor, in_factor, in_second_factor = 32, 32, 4

Review comment:
       Resolved by comment above.




-- 
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] csullivan commented on a change in pull request #8960: [Hexagon] Add contrib tests for blocked conv2d and maxpool2d

Posted by GitBox <gi...@apache.org>.
csullivan commented on a change in pull request #8960:
URL: https://github.com/apache/tvm/pull/8960#discussion_r704786176



##########
File path: tests/python/contrib/test_hexagon/conftest.py
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Hexagon testing fixtures used to deduce testing argument
+    values from testing parameters """
+
+import tvm
+from .infrastructure import ceildiv
+
+
+@tvm.testing.fixture
+def shape_nhwc(batch, in_channel, in_size):
+    return (batch, in_size, in_size, in_channel)
+
+
+@tvm.testing.fixture
+def shape_oihw(out_channel, in_channel, kernel):
+    return (out_channel, in_channel, kernel, kernel)
+
+
+@tvm.testing.fixture
+def shape_oihw8i32o4i(out_channel, in_channel, kernel):
+    out_factor, in_factor, in_second_factor = 32, 32, 4
+    return (
+        int(ceildiv(out_channel, out_factor)),

Review comment:
       Correct, ceiling divide will round up if the input or output channels are not factors of 32.




-- 
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