Version
Function Usage
Upon operator compilation and deployment, a single-operator API (aclnnxxx) is automatically generated, whose input and output parameters are consistent with those in the operator prototype definition.
When adding optional inputs, in order to maintain compatibility of the original single-operator API (aclnnxxx), use the Version API to configure its version number. The version number should start from 1 and be configured continuously (and uniformly numbered with the optional attributes). After the configuration, the automatically generated aclnn API will carry the version number. The API of a later version contains all parameters of the API of an earlier version. The prototype definition is as follows:
class AddCustom : public OpDef {
public:
explicit AddCustom(const char* name) : OpDef(name) {
this->Input("x")
.ParamType(DYNAMIC)
.DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
.Format({ge::FORMAT_ND, ge::FORMAT_ND});
this->Input("x1")
.ParamType(OPTIONAL)
.Version(1)
.DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
.Format({ge::FORMAT_ND, ge::FORMAT_ND});
this->Input("x2")
.ParamType(OPTIONAL)
.Version(2)
.DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
.Format({ge::FORMAT_ND, ge::FORMAT_ND});
this->Output("y")
.ParamType(DYNAMIC)
.DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
.Format({ge::FORMAT_ND, ge::FORMAT_ND});
this->AICore().AddConfig("xxx");
}
};
OP_ADD(AddCustom);
Three versions of aclnn APIs are automatically generated. The definitions are as follows:
aclnnStatus aclnnAddCustomGetWorkspaceSize(
const aclTensorList *x,
const aclTensorList *out,
uint64_t *workspaceSize,
aclOpExecutor **executor);
aclnnStatus aclnnAddCustom(
void *workspace,
uint64_t workspaceSize,
aclOpExecutor *executor,
const aclrtStream stream);
aclnnStatus aclnnAddCustomV1GetWorkspaceSize(
const aclTensorList *x,
const aclTensor *x1Optional,
const aclTensorList *out,
uint64_t *workspaceSize,
aclOpExecutor **executor);
aclnnStatus aclnnAddCustomV1(
void *workspace,
uint64_t workspaceSize,
aclOpExecutor *executor,
const aclrtStream stream);
aclnnStatus aclnnAddCustomV2GetWorkspaceSize(
const aclTensorList *x,
const aclTensor *x1Optional,
const aclTensor *x2Optional,
const aclTensorList *out,
uint64_t *workspaceSize,
aclOpExecutor **executor);
aclnnStatus aclnnAddCustomV2(
void *workspace,
uint64_t workspaceSize,
aclOpExecutor *executor,
const aclrtStream stream);
Prototype
OpParamDef &Version(uint32_t version);
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
version |
Input |
Version number. |
Returns
OpParamDef operator definition. For details, see OpParamDef.
Constraints
None