GetData

Function Usage

Obtains the data address of a tensor.

Prototype

1
2
template<class T>  const T *GetData() const
template<class T>  auto GetData() -> T*

Parameters

Parameter

Input/Output

Description

T

Input

Data type

Returns

Data address

Constraints

None

Examples

1
2
3
4
5
6
Tensor tensor{{{8, 3, 224, 224}, {16, 3, 224, 224}},       // shape                
              {ge::FORMAT_ND, ge::FORMAT_FRACTAL_NZ, {}},  // format                              
              kFollowing,                                  // placement                
              ge::DT_FLOAT16,                              //dt                
              nullptr};
auto addr = tensor.GetData<int64_t>(); // reinterpret_cast<int64_t *>(&tensor + 1)