te.lang.cce.conv(*args)
Computes 2D convolution when the 4D input and filter are specified.
The formats of the input tensor and the filter tensor must be NCHW.
The interface supports bias, and the supported data type is float16.
This API is defined in conv_compute.py.
Parameter Description
- The parameter list for the bias scenario is as follows: (hasBias must be set to True)
A, W, B, res_dtype, padh, padw, strideh, stridew, hasBias
- The parameter list for the non-bias scenario is as follows: (hasBias must be set to False)
A, W, res_dtype, padh, padw, strideh, stridew, hasBias
Where,- A: input tensor, that is, feature map for convolutional calculation
- W: filter tensor, that is, convolutional core for convolutional calculation
- B: bias tensor, that is, offset of convolution calculation
- res_dtype: data type of the output tensor, that is, data type of the convolution calculation result.
- padh: height of padding, that is, number of padding times in the H direction of the feature map during convolutional calculation
- padw: width of padding, that is, number of padding times in the W direction of the feature map during convolutional calculation
- strideh: stride in the H direction, that is, movement stride of the convolutional calculation filter in the H direction on the feature map
- stridew: stride in the W direction, that is, movement stride of the convolutional calculation filter in the W direction on the feature map
- hasBias: whether bias is contained
- Constraints: Assume that the shape of the feature map is (Fn, Fc, Fh, Fw), the shape of filter is (Wn, Wc, Wh, Ww), and the output shape of the convolution result is (On, Oc, Oh, Ow). padh is Ph, padw is Pw, strideh is Sh, and stridew is Sw. These parameters must meet the following requirements:
- Fc = Wc
- On = Fn
- Oc = Wn
- Oh = ((Fh + 2Ph - Wh) / Sh) + 1
- Ow = ((Fw + 2Pw - Ww) / Sw) + 1
Return Value
res_tensor: tensor for convolutional calculation, that is, output of convolutional calculation
Calling Example
import tvm import te.lang.cce shape_in = (64,64) shape_w = (3,3) in_dtype = "float16" A = tvm.placeholder(shape_in, name='A', dtype=in_dtype) W = tvm.placeholder(shape_w, name='W', dtype=in_dtype) b_shape = (shape_w[0], ) B = tvm.placeholder(b_shape, name='B', dtype=res_dtype) padh = 0 padw = 0 strideh = 1 stridew = 1 res = te.lang.cce.conv(A, W, B, in_dtype, padh, padw, strideh, stridew, True) # res = A * W + B
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot