MCPcopy Create free account
hub / github.com/apache/tvm / conv2d_nhwc_python

Function conv2d_nhwc_python

python/tvm/topi/testing/conv2d_nhwc_python.py:81–116  ·  view source on GitHub ↗

Convolution operator in NHWC layout. Parameters ---------- a_np : numpy.ndarray 4-D with shape [batch, in_height, in_width, in_channel] w_np : numpy.ndarray 4-D with shape [filter_height, filter_width, in_channel // groups, num_filter] stride : int or a list/tu

(a_np, w_np, stride, padding, groups=1)

Source from the content-addressed store, hash-verified

79
80
81def conv2d_nhwc_python(a_np, w_np, stride, padding, groups=1):
82 """Convolution operator in NHWC layout.
83
84 Parameters
85 ----------
86 a_np : numpy.ndarray
87 4-D with shape [batch, in_height, in_width, in_channel]
88
89 w_np : numpy.ndarray
90 4-D with shape [filter_height, filter_width, in_channel // groups, num_filter]
91
92 stride : int or a list/tuple of two ints
93 Stride size, or [stride_height, stride_width]
94
95 padding : int or str or a list/tuple of 2 or 4 ints
96 Padding size, or ['VALID', 'SAME'], or
97 [pad_height, pad_width] for 2 ints, or
98 [pad_top, pad_left, pad_bottom, pad_right] for 2 ints
99
100 groups : int
101 Number of groups
102
103 Returns
104 -------
105 b_np : np.ndarray
106 4-D with shape [batch, out_height, out_width, out_channel]
107 """
108
109 a_slices = np.array_split(a_np, groups, axis=3)
110 w_slices = np.array_split(w_np, groups, axis=3)
111 b_slices = [
112 _conv2d_nhwc_python(a_slice, w_slice, stride, padding)
113 for a_slice, w_slice in zip(a_slices, w_slices)
114 ]
115 b_np = np.concatenate(b_slices, axis=3)
116 return b_np

Callers

nothing calls this directly

Calls 2

_conv2d_nhwc_pythonFunction · 0.85
concatenateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…