Function: set_config_opt

Applicable Products

  • Ascend 950PR&950DT products: Supported
  • Atlas A3 products: Supported
  • Atlas A2 products: Supported
  • Atlas 200I/500 A2 inference products: Supported
  • Atlas inference products: Supported
  • Atlas training products: Supported

Function

Sets the value of an attribute in the configuration object for loading a model, including the model execution priority, model file directory or memory address, and memory size.

Prototype

  • C Prototype

    aclError aclmdlSetConfigOpt(aclmdlConfigHandle *handle, aclmdlConfigAttr attr, const void *attrValue, size_t valueSize)
    
  • Python Function

    ret = acl.mdl.set_config_opt(config_handle, attr, attr_value)
    

Parameters

Parameter Description
config_handle Int, pointer address of the configuration object for loading a model. Call acl.mdl.create_config_handle to create the pointer address in advance.
attr Int, attribute to be set. For details about the value, see aclmdlConfigAttr.
attr_value Int/Str, attribute value. For details about the value, see aclmdlConfigAttr.

Return Values

Return Value Description
ret Int, error code: 0 on success; else, failure.

Constraints

This API needs to work with the following APIs to load models:

  1. Call acl.mdl.create_config_handle to create a configuration object for loading a model.
  2. Call acl.mdl.set_config_opt multiple times to set the value of each attribute in the configuration object.
  3. Call acl.mdl.load_with_config to specify the configuration information for model loading and load your model.
  4. Call acl.mdl.destroy_config_handle to destroy the configuration object after the model is successfully loaded.

Reference

For acl.mdl.set_config_opt and acl.mdl.load_with_config, the caller needs to set the attributes in the configuration object passed to the API call to decide how the model will be loaded and who will manage the memory.

By choosing from the following APIs, you can directly determine whether to load a model from a file or from memory and whether the memory is managed by the system or the user.