MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / IsCUDATensor

Function IsCUDATensor

tensorflow/core/common_runtime/direct_session_test.cc:2155–2176  ·  view source on GitHub ↗

A graph that consumes and produces string tensors (which are not GPU-compatible, i.e., there are no GPU kernels for these operations).

Source from the content-addressed store, hash-verified

2153// (which are not GPU-compatible, i.e., there are no
2154// GPU kernels for these operations).
2155bool IsCUDATensor(const Tensor& t) {
2156#ifdef GOOGLE_CUDA
2157 cudaPointerAttributes attributes;
2158 cudaError_t err =
2159 cudaPointerGetAttributes(&attributes, t.tensor_data().data());
2160 if (err == cudaErrorInvalidValue) return false;
2161 CHECK_EQ(cudaSuccess, err) << cudaGetErrorString(err);
2162#if CUDA_VERSION >= 11000
2163 return (attributes.type == cudaMemoryTypeDevice);
2164#else
2165 return (attributes.memoryType == cudaMemoryTypeDevice);
2166#endif
2167#elif TENSORFLOW_USE_ROCM
2168 hipPointerAttribute_t attributes;
2169 hipError_t err = hipPointerGetAttributes(&attributes, t.tensor_data().data());
2170 if (err == hipErrorInvalidValue) return false;
2171 CHECK_EQ(hipSuccess, err) << hipGetErrorString(err);
2172 return (attributes.memoryType == hipMemoryTypeDevice);
2173#else
2174 return false;
2175#endif
2176}
2177
2178string GPUDeviceName(Session* session) {
2179 std::vector<DeviceAttributes> devices;

Callers 2

TESTFunction · 0.70

Calls 2

tensor_dataMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected