---
title: 函数：cast
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/aclpythondevg_01_0778.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/aclpythondevg_01_0778.html
indexId: 80d221909653c6772c831b38f519155646d0a36e53a6ed3423bc2d84ad491e6875
---
# 函数：cast

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |


#### 功能说明

转换输入数据的数据类型，异步接口。


#### 函数原型

- C函数原型
  1 aclError aclopCast(const aclTensorDesc *srcDesc, const aclDataBuffer *srcBuffer, const aclTensorDesc *dstDesc, aclDataBuffer *dstBuffer, uint8_t truncate, aclrtStream stream)

- python函数
  1 ret = acl.op.cast(src_desc, src_buffer, dst_desc, dst_buffer, truncate, stream)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| src\_desc | int，输入Tensor描述指针地址。 |
| src\_buffer | int，输入Tensor，调用acl.create\_data\_buffer(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg\_01\_0016.html)创建的aclDataBuffer指针地址。 |
| dst\_desc | int， 输出Tensor的描述指针地址。 |
| dst\_buffer | int，输出Tensor，调用acl.create\_data\_buffe(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg\_01\_0016.html)r创建的aclDataBuffer指针地址。 |
| truncate | int，预留。 |
| stream | int，执行算子所在的Stream，Stream地址对象。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| ret | int，错误码，返回0表示成功，返回其它值表示失败。 |


#### 资源参考

接口调用示例，参见接口调用流程(https://www.hiascend.comdocument/detail/zh/canncommercial/900/programug/acldevg/aclpythondevg_0069.html)。
