---
title: MallocOutputTensor
description: "- 头文件：#include <exe_graph/runtime/eager_op_execution_context.h>"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/atlasgeapi_07_0695.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/atlasgeapi_07_0695.html
indexId: a62ae3450e01562baddf6f262e76bd9eb4c2ed5871cbf6bdef559876d85eefd572
---
# MallocOutputTensor

#### 头文件/库文件

- 头文件：#include <exe_graph/runtime/eager_op_execution_context.h>
- 库文件：liblowering.so


#### 功能说明

为某个输出Tensor申请Device内存，同时初始化输出Tensor的基本信息。

该输出Tensor的内存由Context构造方管理。接口调用者不需要主动释放。


#### 函数原型

```
Tensor *MallocOutputTensor(size_t index, const StorageShape &shape, const StorageFormat &format, ge::DataType dtype, size_t tensor_size)
```


#### 参数说明

| 参数名 | 输入/输出 | 描述 |
| --- | --- | --- |
| index | 输入 | 输出索引。 |
| shape | 输入 | 输出tensor的shape。 |
| format | 输入 | 输出tensor的format。 |
| dtype | 输入 | 输出tensor的data type。 |
| tensor\_size | 输入 | 输出tensor的大小，单位为字节。 |


#### 返回值说明

Tensor指针，异常时返回空指针。


#### 约束说明

无
