From d84c7ecd89945ec564011c4963d6db000641fdf6 Mon Sep 17 00:00:00 2001 From: RexYing Date: Tue, 26 Apr 2022 00:50:13 +0000 Subject: [PATCH] out of range exception catching --- csrc/cpu/neighbor_sample_cpu.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/csrc/cpu/neighbor_sample_cpu.cpp b/csrc/cpu/neighbor_sample_cpu.cpp index 42b3ed14..3aa287c8 100644 --- a/csrc/cpu/neighbor_sample_cpu.cpp +++ b/csrc/cpu/neighbor_sample_cpu.cpp @@ -117,10 +117,12 @@ sample(const torch::Tensor &colptr, const torch::Tensor &row, inline bool satisfy_time(const c10::Dict &node_time_dict, const node_t &src_node_type, int64_t dst_time, int64_t src_node) { - try { // Check whether src -> dst obeys the time constraint: + try { + // Check whether src -> dst obeys the time constraint const torch::Tensor &src_node_time = node_time_dict.at(src_node_type); return src_node_time.data_ptr()[src_node] <= dst_time; - } catch (int err) { // If no time is given, fall back to normal sampling: + } catch (const std::out_of_range& e) { + // If no time is given, fall back to normal sampling return true; } }