Verification Procedure
After an operator is deployed in the hardware environment of the Ascend AI Processor, write test cases to build a TensorFlow or MindSpore network that contains the operator to be verified and check whether the operator runs properly on the network.
To simplify the network construction process, we construct a single-operator network that contains only the operator to be verified. During result verification, you can compare the operator running result in the hardware environment where the Ascend AI Processor is located with the expected result to verify operator functions.
Verification Flow
- Develop operators and deploy related deliverables on the host, including the operator implementation file, operator plug-in (required only when the test frontend is the TensorFlow network), operator prototype library and operator information library.
- Select a case to be tested and specify the shape and data type.
- Use NumPy or other tools to generate random data as the operator input data.
- Based on the input data, execute the operator in the TensorFlow environment or operator computing process simulated by using NumPy to obtain the expected running result.
- Use the TensorFlow frontend to construct a single-operator network that contains only the developed TBE operator, and use the data in 3 as the input to execute the single-operator network.TensorFlow calls the GE or FE and executes the single-operator network in the hardware environment of Ascend AI Processor to obtain the actual operator running result. The process is as follows:
- Adapt a TF Adapter and upload a plug-in. If the TensorFlow frontend is used, the API adapted to the TF Adapter is called to construct a TensorFlow graph and sends the graph to the GE. The graph is then loaded during GE initialization. The parser() interface is called to parse the operator and map it to a graph supported by the Ascend AI processor.
- GE calls infershape()/verify() in the operator prototype library to perform shape inference and parameters validity verification.
- The FE loads the operator information library which registers the operator information and specifies that the input parameters of the operator during execution in the Ascend AI Processor, including the shape, type, and format.
- The FE calls the TBE operator library to perform UB fusion and build the operator implementation file to generate the operator kernel.
- The GE delivers the task info obtained from FE to Runtime, and then sends the task info to the device through the driver. Execute the single-operator network on the Ascend AI Processor to obtain the actual operator running result.
- Compare the execution result in the Ascend AI Processor in 5 with the expected result in 4 to check whether the function is correct and whether the precision meets the requirements.