---
title: LinearParam
description: "| 属性 | 类型 | 默认值 | 描述 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendtb/ascendtb_01_0335.html
sourcePath: /source/zh/canncommercial/900/API/ascendtb/ascendtb_01_0335.html
indexId: 3378484f983fc56b887a373fd8df438a9070fbdb06783c6c518a86a5789bb11e64
---
# LinearParam

| 属性 | 类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| transpose\_a | bool | False | \- |
| transpose\_b | bool | True | \- |
| has\_bias | bool | True | \- |
| out\_data\_type | torch\_atb.AclDataType | torch\_atb.AclDataType.ACL\_DT\_UNDEFINED | 根据输入tensors自动推导输出tensors数据类型。 |
| en\_accum | bool | False | \- |
| matmul\_type | torch\_atb.LinearParam.MatmulType | torch\_atb.LinearParam.MatmulType.MATMUL\_UNDEFINED | \- |


#### LinearParam.MatmulType

枚举项：

- MATMUL_UNDEFINED
- MATMUL_EIN_SUM


#### 调用示例

```
import torch
import torch_atb

def linear():
    m, k, n = 3, 4, 5
    input_tensor = torch.randn(m, k, dtype=torch.float16).npu()
    weight_tensor = torch.randn(k, n, dtype=torch.float16).npu()
    print(input_tensor)
    print(weight_tensor)

    linear_param = torch_atb.LinearParam(has_bias = False, transpose_b = False)
    linear = torch_atb.Operation(linear_param)

    def linear_run():
        linear_outputs = linear.forward([input_tensor, weight_tensor])
        return [linear_outputs[0].to(torch.float32)]


    outputs = linear_run()
    print("outputs: ", outputs)

if __name__ == "__main__":
    linear()
```
