Description: Sends tensor x and configuration parameters (such as param and cmd) to the PMCC obfuscation engine. The CA module of the engine calls the TA module to perform tensor obfuscation and returns the obfuscated tensor y with the same shape as x.
Background: The Privacy&Model Confidential Computing (PMCC) model obfuscation feature uses the TrustZone trusted operating environment in the CPU core to isolate and store obfuscation factors, derive obfuscation masks, and dynamically add masks. Based on the NPU TrustZone, the PMCC builds the model obfuscation engine CA (Client Application in the common OS) and model obfuscation engine TA (Trusted Application in the TEE OS). To enable the model to access the model obfuscation engine TA during inference execution, the AI CPU operator mechanism and the localhost socket in the NPU are used for forwarding.
Each operator has calls. First, aclnnObfuscationCalculateGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnObfuscationCalculate is called to perform computation.
[object Object][object Object]
Parameters:
- fd (int32_t, compute input): socket connection symbol. The data type is INT32. Set this parameter to fd[0] in the output of aclnnObfuscationSetup during resource initialization.
- x (aclTensor*, compute input): tensor to be obfuscated. The shape is (,,...,hiddenSize). The size of the last dimension of the shape is the hiddenSize configured by aclnnObfuscationSetup during resource initialization. The can be ND. and empty tensors are not supported.
- [object Object]Atlas inference series products[object Object]: The data type can be FLOAT, FLOAT16, or INT8.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: The tensor data type can be FLOAT, FLOAT16, INT8, or BFLOAT16.
- param (int32_t, compute input): reserved parameter field. The data type is INT32. The current version supports only 0.
- cmd (int32_t, compute input): obfuscation operator instruction ID. The current version supports only 1.
- y (aclTensor*, compute output): tensor after obfuscation. The data type and shape are the same as those of x. The can be ND. and empty tensors are not supported.
- workspaceSize (uint64_t*, output): size of the workspace to be allocated on the device.
- executor (aclOpExecutor**, output): operator executor, containing the operator computation process.
Returns:
Parameters:
- workspace (void*, input): address of the workspace to be allocated on the device.
- workspaceSize (uint64_t, input): size of the workspace to be allocated on the device, which is obtained by the first-phase API aclnnObfuscationCalculateGetWorkspaceSize.
- executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
- stream (aclrtStream, input): stream for executing the task.
Deterministic compute:
- aclnnObfuscationCalculate defaults to a deterministic implementation.
This API is used together with to obfuscate the PMCC model. The usage methods are as follows:
- Call aclnnObfuscationSetup to initialize resources. This function can be called repeatedly, but only the last initialization takes effect.
- Call aclnnObfuscationCalculate multiple times to perform tensor obfuscation.
- Call aclnnObfuscationSetup to release resources. This function can be called only once. You can also terminate the program process to release resources instead of explicitly releasing resources.
The following example is for reference only. For details, see .