算子json配置文件样例
============

#### 样例1：NPU/CPU调测算子json配置文件样例

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/0/v3/U5rsepb5RmaUZxQPMjfG0g/note_3.0-zh-cn.png?HW-CC-KV=V1&HW-CC-Date=20260612T073701Z&HW-CC-Expire=86400&HW-CC-Sign=FD807764E7F183DE740AF3BAFFFCEC6B20370C11D516B867B73AADFBE803DB6C)

*   在"param\_type"："optional"时，"ignore"：true，表示不需要该输入；"ignore"：false，表示需要该输入。
    
*   在"param\_type"："required"时，"ignore"不能配置为true。
    

{
  "op\_type": "FlashAttentionScore",
  "data\_script": "./flash\_attention\_score\_golden.py",
  "gen\_data": true,
  "inputs": \[
    {
      "name": "query",
      "dtype": "float16",
      "format": "ND",
      "ignore": false,
      "shape": \[24,144,1280\],
      "param\_type": "required",
      "data\_file": "q.bin"
    },
    {
      "name": "key",
      "dtype": "float16",
      "format": "ND",
      "ignore": false,
      "shape": \[24,144,1280\],
      "param\_type": "required",
      "data\_file": "k.bin"
    },
    {
      "name": "value",
      "dtype": "float16",
      "format": "ND",
      "ignore": false,
      "shape": \[24,144,1280\],
      "param\_type": "required",
      "data\_file": "v.bin"
    },
  \],
  "outputs": \[
    {
      "name": "softmax\_max",
      "dtype": "float32",
      "format": "ND",
      "shape": \[24,20,144,8\],
      "ignore": false,
      "param\_type": "required",
      "data\_file": null
    },
    {
      "name": "softmax\_sum",
      "dtype": "float32",
      "format": "ND",
      "shape": \[24,20,144,8\],
      "ignore": false,
      "param\_type": "required",
      "data\_file": null
    },
    {
      "name": "softmax\_out",
      "dtype": "float16",
      "format": "ND",
      "shape": \[24,20,144,144\],
      "ignore": false,
      "param\_type": "required",
      "data\_file": null
    },
    {
      "name": "attention\_out",
      "dtype": "float16",
      "format": "ND",
      "shape": \[24,20,144,64\],
      "ignore": false,
      "param\_type": "required",
      "data\_file": "attention\_out.bin"
    }
  \],
  "attrs": \[
    {
      "name": "scale\_value",
      "dtype": "float",
      "value": 1.0
    },
    {
      "name": "keep\_prob",
      "dtype": "float",
      "value": 0.8
    },
    {
      "name": "pre\_tokens",
      "dtype": "int",
      "value": 2147483647
    },
    {
      "name": "next\_tokens",
      "dtype": "int",
      "value": 2147483647
    },
    {
      "name": "head\_num",
      "dtype": "int",
      "value": 20
    },
    {
      "name": "input\_layout",
      "dtype": "string",
      "value": "BSH"
    },
    {
      "name": "inner\_precise",
      "dtype": "int",
      "value": 0
    }
  \]
}

#### 样例2：tensor list json配置文件样例

{
  "op\_type": "IncreFlashAttention",
  "data\_script": "",
  "gen\_data": false,
  "inputs": \[
      {
          "name": "query",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[4, 5, 1, 128\],
          "param\_type": "required",
          "data\_file": "/home/data/input/q.bin"
      },
      \[{
          "name": "key0",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[1,5,8192,128\],
          "param\_type": "required",
          "data\_file": "/home/data/input/k\_0.bin"
      },{
          "name": "key1",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[1,5,8192,128\],
          "param\_type": "required",
          "data\_file": "/home/data/input/k\_1.bin"
      },{
          "name": "key2",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[1,5,8192,128\],
          "param\_type": "required",
          "data\_file": "/home/data/input/k\_2.bin"
      },{
          "name": "key3",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[1,5,8192,128\],
          "param\_type": "required",
          "data\_file": "/home/data/input/k\_3.bin"
      }\],
      \[{
          "name": "value0",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[1,5,8192,128\],
          "param\_type": "required",
          "data\_file": "/home/data/input/v\_0.bin"
      },{
          "name": "value1",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[1,5,8192,128\],
          "param\_type": "required",
          "data\_file": "/home/data/input/v\_1.bin"
      },{
          "name": "value2",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[1,5,8192,128\],
          "param\_type": "required",
          "data\_file": "/home/data/input/v\_2.bin"
      },{
          "name": "value3",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[1,5,8192,128\],
          "param\_type": "required",
          "data\_file": "/home/data/input/v\_3.bin"
      }\],
      {
          "name": "padding\_mask",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": null,
          "param\_type": "optional",
          "data\_file": null
      },
      {
          "name": "atten\_mask",
          "dtype": "float16",
          "format": "ND",
          "ignore": false,
          "shape": \[4,1,8192\],
          "param\_type": "optional",
          "data\_file": "/home/data/input/attenMask.bin"
      },
      {
          "name": "actual\_seq\_lengths",
          "dtype": "int64",
          "format": "ND",
          "ignore": false,
          "shape": null,
          "param\_type": "optional",
          "data\_file": ""
      },
      {
          "name": "deq\_scale1",
          "dtype": "uint64",
          "format": "ND",
          "ignore": false,
          "shape": null,
          "param\_type": "optional",
          "data\_file": null
      },
      {
          "name": "quant\_scale1",
          "dtype": "float32",
          "format": "ND",
          "ignore": false,
          "shape": null,
          "param\_type": "optional",
          "data\_file": null
      },
      {
          "name": "deq\_scale2",
          "dtype": "uint64",
          "format": "ND",
          "ignore": false,
          "shape": null,
          "param\_type": "optional",
          "data\_file": null
      },
      {
          "name": "quant\_scale2",
          "dtype": "float32",
          "format": "ND",
          "ignore": false,
          "shape": null,
          "param\_type": "optional",
          "data\_file": null
      },
      {
          "name": "quant\_offset2",
          "dtype": "float32",
          "format": "ND",
          "ignore": false,
          "shape": null,
          "param\_type": "optional",
          "data\_file": null
      }
  \],
  "outputs": \[
      {
          "name": "attention\_out",
          "dtype": "float16",
          "format": "ND",
          "shape": \[4, 5, 1, 128\],
          "ignore": false,
          "param\_type": "required",
          "data\_file": "/home/data/output/y\_add.bin"
      }
  \],
  "attrs": \[
      {
          "name": "num\_heads",
          "dtype": "int",
          "value": 5
      },
      {
          "name": "scale\_value",
          "dtype": "float",
          "value": 2.0
      },
      {
          "name": "input\_layout",
          "dtype": "string",
          "value": "BNSD"
      },
      {
          "name": "num\_key\_value\_heads",
          "dtype": "int",
          "value": 5
      }
  \]}

#### 样例3：tiling调测json配置文件样例

{
  "op\_type": "FlashAttentionScore",
  "data\_script": "./flash\_attention\_score\_golden.py",
  "gen\_data": true,
  "inputs": \[
    {
      "name": "query",
      "dtype": "float16",
      "format": "ND",
      "ignore": false,
      "shape": \[24,144,1280\],
      "param\_type": "required",
      "data\_file": "q.bin"
    },
    {
      "name": "key",
      "dtype": "float16",
      "format": "ND",
      "ignore": false,
      "shape": \[24,144,1280\],
      "param\_type": "required",
      "data\_file": "k.bin"
    },
    {
      "name": "value",
      "dtype": "float16",
      "format": "ND",
      "ignore": false,
      "shape": \[24,144,1280\],
      "param\_type": "required",
      "data\_file": "v.bin"
    },
    {
      "name": "real\_shift",
      "dtype": "float16",
      "format": "ND",
      "ignore": false,
      "shape": null,
      "param\_type": "optional",
      "data\_file": null
    },
    {
      "name": "drop\_mask",
      "dtype": "uint8",
      "format": "ND",
      "ignore": false,
      "shape": \[1244160\],
      "param\_type": "optional",
      "data\_file": "drop\_mask.bin"
    },
    {
      "name": "padding\_mask",
      "dtype": "float16",
      "format": "ND",
      "ignore": false,
      "shape": null,
      "param\_type": "optional",
      "data\_file": null
    },
    {
      "name": "atten\_mask",
      "dtype": "bool",
      "format": "ND",
      "ignore": false,
      "shape": null,
      "param\_type": "optional",
      "data\_file": null
    },
    {
      "name": "prefix",
      "dtype": "int64",
      "format": "ND",
      "ignore": false,
      "shape": null,
      "param\_type": "optional",
      "data\_file": null
    }
  \],
  "outputs": \[
    {
      "name": "softmax\_max",
      "dtype": "float32",
      "format": "ND",
      "shape": \[24,20,144,8\],
      "ignore": false,
      "param\_type": "required",
      "data\_file": null
    },
    {
      "name": "softmax\_sum",
      "dtype": "float32",
      "format": "ND",
      "shape": \[24,20,144,8\],
      "ignore": false,
      "param\_type": "required",
      "data\_file": null
    },
    {
      "name": "softmax\_out",
      "dtype": "float16",
      "format": "ND",
      "shape": \[24,20,144,144\],
      "ignore": false,
      "param\_type": "required",
      "data\_file": null
    },
    {
      "name": "attention\_out",
      "dtype": "float16",
      "format": "ND",
      "shape": \[24,20,144,64\],
      "ignore": false,
      "param\_type": "required",
      "data\_file": "attention\_out.bin"
    }
  \],
  "attrs": \[
    {
      "name": "scale\_value",
      "dtype": "float",
      "value": 1.0
    },
    {
      "name": "keep\_prob",
      "dtype": "float",
      "value": 0.8
    },
    {
      "name": "pre\_tokens",
      "dtype": "int",
      "value": 2147483647
    },
    {
      "name": "next\_tokens",
      "dtype": "int",
      "value": 2147483647
    },
    {
      "name": "head\_num",
      "dtype": "int",
      "value": 20
    },
    {
      "name": "input\_layout",
      "dtype": "string",
      "value": "BSH"
    },
    {
      "name": "inner\_precise",
      "dtype": "int",
      "value": 0
    }
  \]
}

#### 样例4：kernel直调json配置样例

{
    "op\_type": "add\_custom",
    "data\_script": "",
    "gen\_data": false,
    "params": \[
            {
                "name": "x",
                "dtype": "float16",
                "param\_type": "input",
                "shape": \[
                    1,16384
                \],
                "data\_file": "input\_x.bin"
            },
            {
                "name": "y",
                "dtype": "float16",
                "param\_type": "input",
                "shape": \[
                    1,16384
                \],
                "data\_file": "input\_y.bin"
            },
            {
                "name": "z",
                "dtype": "float16",
                "param\_type": "output",
                "shape": \[
                    1,16384
                \],
                "data\_file": "golden.bin"
            },
            {
                "name": "tileNumIn",
                "dtype": "uint32",
                "param\_type": "input",
                "shape": null,
                "data\_value": 8
            }
    \],
    "kernel\_info": {
        "kernel\_source": \["add\_custom.cpp"\],
        "kernel\_name": "add\_custom",
        "kernel\_includes": \[\]
    }
 
}