#pragma once #include #include namespace deep_ep::elastic { static at::cuda::CUDAStream get_global_comm_stream() { static std::optional comm_stream = std::nullopt; if (not comm_stream.has_value()) comm_stream = at::cuda::getStreamFromPool(true); return comm_stream.value(); } template static auto get_shape(const torch::Tensor& t) { EP_HOST_ASSERT(t.dim() == kNumDims); return [&t] (std::index_sequence) { return std::make_tuple(static_cast(t.sizes()[Is])...); }(std::make_index_sequence()); } template static dtype_t* get_data_ptr(const std::optional& t) { return t.has_value() ? t->data_ptr() : nullptr; } } // deep_ep::elastic