TensorPlacementUtils
函数功能
提供一组函数,判断TensorPlacement的位置。
函数原型
class TensorPlacementUtils {
public:
// 判断Tensor是否位于Device上的内存
static bool IsOnDevice(TensorPlacement placement) {
...
}
// 判断Tensor是否位于Host上
static bool IsOnHost(TensorPlacement placement) {
...
}
// 判断Tensor是否位于Host上,且数据紧跟在结构体后面
static bool IsOnHostFollowing(TensorPlacement placement) {
...
}
// 判断Tensor是否位于Host上,且数据不紧跟在结构体后面
static bool IsOnHostNotFollowing(TensorPlacement placement) {
...
}
// 判断Tensor是否位于Device上的内存
static bool IsOnDeviceHbm(TensorPlacement placement) {
...
}
// 判断Tensor是否位于Device上的P2p内存
static bool IsOnDeviceP2p(TensorPlacement placement) {
...
}
};
参数说明
返回值说明
true表示是;false表示不是。
约束说明
无。
调用示例
TensorData tensor_data;
tensor_data.SetPlacement(TensorPlacement::kOnHost);
auto on_host = TensorPlacementUtils::IsOnHost(tensor_data.GetPlacement()); // on_host is true