aclopInferShape
Applicability
|
Product |
Supported |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Description
Infers the output shape of an operator based on the input shape and other necessary arguments.
- If the accurate output shape of the operator can be inferred, the accurate output shape is returned.
- If the accurate output shape of the operator cannot be inferred, but the range of the output shape can be obtained, the dynamic dimension in the tensor description is set to –1 in the output parameter outputDesc. In this scenario, you can call aclGetTensorDescDimRange to obtain the size range of the specified dimension from the tensor description.
- (Reserved) If the accurate output shape and shape range cannot be obtained, the runtime dimension in the tensor description is set to –2 in the output parameter outputDesc.
Prototype
aclError aclopInferShape(const char *opType, int numInputs, aclTensorDesc *inputDesc[], aclDataBuffer *inputs[], int numOutputs, aclTensorDesc *outputDesc[], aclopAttr *attr)
Parameters
|
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 to create data of the aclDataBuffer type in advance. In In In Open Ctrl CPU form form, allocate device memory for storing the input tensor data of the operator. 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. |
Returns
0 on success; else, failure. For details, see aclError.
Restrictions
- For a required input, optional input, or required output, use the exact name defined in the operator IR prototypes.
- For a dynamic input or dynamic output, use the exact name defined in the operator IR prototypes with a sequence number suffix. Dynamic inputs/outputs are indexed starting at 0.
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");