Skip to content
Snippets Groups Projects
Commit c7c9fba9 authored by auphelia's avatar auphelia
Browse files

Merge quetric-feature/ConvolutionInputGenerator_kernel_stride into feature/conv_input_gen_dws

parents 37c4a0b5 93897708
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,6 @@ class ConvolutionInputGenerator(HLSCustomOp):
pad = 0
ofm_dim = compute_conv_output_dim(ifm_dim, k, stride, pad)
assert ifm_ch % simd == 0, "SIMD must divide IFMChannels"
assert k % stride == 0, "stride must divide kernel size k"
wf = int((k * k * ifm_ch) // simd)
folded_oshape = (1, ofm_dim, ofm_dim, wf, simd)
return folded_oshape
......@@ -314,18 +313,25 @@ class ConvolutionInputGenerator(HLSCustomOp):
"ultra": "ap_resource_uram()",
}
hls_ram_style = map_to_hls_ram_style[ram_style]
hls_call = node.op_type
# check if non optimized ConvolutionInputGenerator is needed
k = self.get_nodeattr("ConvKernelDim")
stride = self.get_nodeattr("Stride")
if k % stride != 0:
hls_call += "_kernel_stride"
if self.get_nodeattr("depthwise") == 1:
self.code_gen_dict["$DOCOMPUTE$"] = [
"""{}_dws<ConvKernelDim1, IFMChannels1, Input_precision1, IFMDim1,
OFMDim1, SIMD1, Stride1> (in0, out, numReps, {});""".format(
node.op_type, hls_ram_style
hls_call, hls_ram_style
)
]
else:
self.code_gen_dict["$DOCOMPUTE$"] = [
"""{}<ConvKernelDim1, IFMChannels1, Input_precision1, IFMDim1,
OFMDim1, SIMD1, Stride1> (in0, out, numReps, {});""".format(
node.op_type, hls_ram_style
hls_call, hls_ram_style
)
]
......
......@@ -21,8 +21,6 @@ def get_im2col_indices_nchw(
"""Returns im2col indices."""
# First figure out what the size of the output should be
N, C, H, W = x_shape
assert (H + 2 * padding - field_height) % stride_y == 0
assert (W + 2 * padding - field_width) % stride_x == 0
out_height = compute_conv_output_dim(H, field_height, stride_y, padding)
out_width = compute_conv_output_dim(W, field_width, stride_x, padding)
......
......@@ -127,7 +127,7 @@ def prepare_inputs(input_tensor):
# input datatype
@pytest.mark.parametrize("idt", [DataType.BIPOLAR, DataType.INT2])
# kernel size
@pytest.mark.parametrize("k", [2, 4])
@pytest.mark.parametrize("k", [2, 3, 4])
# input dimension
@pytest.mark.parametrize("ifm_dim", [6, 8])
# input channels
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment