From 1784b0db2f5891d969cabaa6857997b8963da828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 27 Aug 2024 23:34:15 +0200 Subject: [PATCH] Bubble up exceptions in EXLA.DeviceBuffer --- exla/lib/exla/defn/buffers.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exla/lib/exla/defn/buffers.ex b/exla/lib/exla/defn/buffers.ex index d8bce0a4a5..c5908b876b 100644 --- a/exla/lib/exla/defn/buffers.ex +++ b/exla/lib/exla/defn/buffers.ex @@ -109,7 +109,13 @@ defmodule EXLA.Defn.Buffers do case data do %EXLA.Backend{buffer: %EXLA.DeviceBuffer{ref: ref} = buffer} when node(ref) != node() -> - binary = :erpc.call(node(ref), EXLA.DeviceBuffer, :read, [buffer]) + try do + :erpc.call(node(ref), EXLA.DeviceBuffer, :read, [buffer]) + catch + :error, {:exception, reason, stacktrace} -> + reraise Exception.normalize(:error, reason, stacktrace), stacktrace + end + EXLA.BinaryBuffer.from_binary(binary, to_typespec(tensor)) %EXLA.Backend{buffer: %EXLA.DeviceBuffer{} = buffer}