TensorPlacementUtils

Description

Provides a group of functions to determine the position of TensorPlacement.

Prototype

class TensorPlacementUtils {
 public:
  // Check whether a tensor is located in the memory on the device.
  static bool IsOnDevice(TensorPlacement placement) {
    ...
  }
  // Check whether a tensor is located on the host.
  static bool IsOnHost(TensorPlacement placement) {
    ...
  }
  // Check whether a tensor is located on the host and whether the data follows the structure.
  static bool IsOnHostFollowing(TensorPlacement placement) {
    ...
  }
  // Check whether a tensor is located on the host and whether the data does not follow the structure.
  static bool IsOnHostNotFollowing(TensorPlacement placement) {
    ...
  }
  // Check whether a tensor is located in the memory on the device.
  static bool IsOnDeviceHbm(TensorPlacement placement) {
    ...
  }
  // Check whether a tensor is located in the P2P memory on the device.
  static bool IsOnDeviceP2p(TensorPlacement placement) {
    ...
  }
};

Parameters

Parameter

Input/Output

Description

placement

Input

TensorPlacement enumeration to be determined.

Returns

true: yes; false: no.

Restrictions

None

Example

TensorData tensor_data;
tensor_data.SetPlacement(TensorPlacement::kOnHost);
auto on_host = TensorPlacementUtils::IsOnHost(tensor_data.GetPlacement()); // on_host is true