Infers the output shape of an operator based on the input shape and other necessary arguments.
For example, if an operator has two inputs (the first one is required input x, the second one is dynamic input y, including two inputs) and one required output z, the code for calling the aclSetTensorDescName API is as follows.
aclSetTensorDescName(inputTensorDesc[0], "x"); aclSetTensorDescName(inputTensorDesc[1], "y0"); aclSetTensorDescName(inputTensorDesc[2], "y1"); aclSetTensorDescName(outputTensorDesc[0], "z");
aclError aclopInferShape(const char *opType,
int numInputs,
aclTensorDesc *inputDesc[],
aclDataBuffer *inputs[],
int numOutputs,
aclTensorDesc *outputDesc[],
aclopAttr *attr)
Parameter |
Input/Output |
Description |
|---|---|---|
opType |
Input |
Pointer to the operator type name. |
numInputs |
Input |
Number of input tensors. |
inputDesc |
Input |
Pointer array of the input tensor description. Call aclCreateTensorDesc to create data of the aclTensorDesc type in advance. The array length is consistent with numInputs. |
inputs |
Input |
Pointer array of the input tensors. Call aclCreateDataBuffer to create data of the aclDataBuffer type in advance. Determine the memory allocation method based on the app run mode. If the app runs on the host, allocate host memory. If the app runs on the device, allocate device memory. For details about the memory allocation API, see Memory Management. |
numOutputs |
Input |
Number of output tensors. |
outputDesc |
Output |
Pointer array of the output tensor description. Call aclCreateTensorDesc to create data of the aclTensorDesc type in advance. The array length is consistent with numOutputs. |
attr |
Input |
Operator attributes. |
0 on success; else, failure.
For the API call example, see Executing a Dynamic-Shape Operator (No Operator Selector Registered).