函数:execute_v2
产品支持情况
| 
          产品  | 
        
          是否支持  | 
       
|---|---|
| 
          | 
        
          √  | 
       
| 
          | 
        
          √  | 
       
| 
          | 
        
          √  | 
       
| 
          | 
        
          √  | 
       
| 
          | 
        
          √  | 
       
| 
          | 
        
          √  | 
       
使用说明
| 
          C函数原型  | 
        
          aclError aclopExecuteV2(const char *opType, int numInputs, aclTensorDesc *inputDesc[], aclDataBuffer *inputs[], int numOutputs, aclTensorDesc *outputDesc[], aclDataBuffer *outputs[], aclopAttr *attr, aclrtStream stream);  | 
       
|---|---|
| 
          Python函数  | 
        
          ret = acl.op.execute_v2(op_type, input_desc, inputs, output_desc, outputs, attr, stream)  | 
       
| 
          函数功能  | 
        
          执行指定的算子。  | 
       
| 
          输入说明  | 
        
          op_type:str,指定算子类型名称。 input_desc:list,表示算子输入Tensor的描述, 整形列表,包含多个acl的Tensor描述地址对象。 inputs:list,表示算子输入Tensor,整形列表,包含多个aclDataBuffer数据地址对象。 output_desc:list,表示算子输出Tensor的描述,整形列表,包含多个acl的Tensor描述地址对象。 outputs:list,表示算子输出Tensor,整形列表,包含多个aclDataBuffer数据地址对象。 attr:int,算子的属性地址对象。 stream:int,该算子需要加载的Stream对象。  | 
       
| 
          返回值说明  | 
        
          ret:int,错误码。 
  | 
       
| 
          约束说明  | 
        
          该接口是异步接口,调用接口成功仅表示任务下发成功,不表示任务执行成功。调用该接口后,需调用同步等待接口(例如,acl.rt.synchronize_stream)确保任务已执行完成。 多线程场景下,不支持调用本接口时指定同一个Stream或使用默认Stream,否则可能任务执行异常。 每个算子的输入、输出、属性不同,需要应用在调用时严格按照算子输入、输出、属性来组织算子。用户在调用acl.op.execute_v2接口时,根据op_type、输入Tensor的描述、输出Tensor的描述、attr等信息查找对应的任务,并下发执行。 
          对于支持动态Shape的算子,无法明确算子输出Shape时,可调用acl.op.infer_shape接口获取算子的输出Shape:
           
         
 
          执行有可选输入的算子时,如果可选输入不使用:
           
         
 执行有constant输入的算子时,需要先调用acl.set_tensor_const接口设置constant输入。 调用acl.op.execute_v2接口时,设置的constant输入数据必须保持一致。 对于算子有constant输入的场景,如果未调用acl.set_tensor_const接口设置constant输入,则需调用acl.set_tensor_place_ment设置TensorDesc的placement属性,将memType设置为Host内存。 在执行单算子时,一般要求用户传入的输入/输出Tensor数据是存放在Device内存的,比如两个Tensor相加的场景。但是,也存在部分算子,除了将featureMap、weight等Device内存中的Tensor数据作为输入外,还需Tensor shape信息、learningRate、Tensor的dims信息等通常在Host内存中的Tensor数据也作为输入,此时,用户不需要额外将这些Host内存中的Tensor数据拷贝到Device上作为输入,只需要调用acl.set_tensor_place_ment接口设置对应TensorDesc的placement属性为Host内存,在执行单算子时,设置了placement属性为Host内存的TensorDesc,其对应的Tensor数据必须存放在Host内存中,内部会自动将Host上的Tensor数据拷贝到Device上。  | 
       
| 
          参考资源  |