---
title: SetOffset
description: "设置Tensor中的offset。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/maintenref/basicdataapi/atlasopapi_07_00768.html
sourcePath: /source/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi_07_00768.html
indexId: 5a11a66b7f4bce2da506dff87659932dac6a18abf4c0d41643048e2956203e3278
---
# SetOffset

#### 函数功能

设置Tensor中的offset。


#### 函数原型

```
void SetOffset(const int64_t offset)
```


#### 参数说明

Tensor的offset。


#### 返回值说明

无


#### 约束说明

无


#### 调用示例

```
StorageShape sh({1, 2, 3}, {1, 2, 3});
Stride str({6, 3, 1});
TensorV2 t = {sh, {ge::FORMAT_ND, ge::FORMAT_FRACTAL_NZ, {}}, kOnHost, ge::DT_FLOAT, nullptr,nullptr, str, 0};
t.SetOffset(10);
auto offset = t.GetOffset(); // 10
```
