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-unsubscr...@tvm.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org