Help us understand the problem. What is going on with this article?

numbaのjitではtry-catch節がエラーになる

More than 1 year has passed since last update.

この記事は要約です。詳細は以下のリンク先ブログ記事をご覧ください。

http://coffeebreakscript.hatenablog.com/entry/2018/06/18/143536

numba@jitを使って定義した関数の中ではtry-catch節を用いた例外処理が使えません。
たとえば、次のようなコードを動かすと…

from numba import jit

@jit
def function_name(input_args):
    hoge ...
    try:
        hoge1
    exception ERROR:
        hoge2

    return hoge

こんな感じのエラーが出ます。(最後の4行だけ抜粋)

    (前略)
  File "C:\ProgramData\Anaconda3\lib\site-packages\numba\controlflow.py", line 515, in run
    assert not inst.is_jump, inst
AssertionError: Failed at object (analyzing bytecode)
SETUP_EXCEPT(arg=XXX, lineno=XXX)

※arg=とlineno=の後のXXXには本来なら数字が入ります。

今のところ回避策はないようです。
『try-catchを使いたい場合は@jitを使わない』というのが唯一の対処法っぽい。(回避策ご存知の方はコメント欄までお願いいたします。)

■参考サイト:
https://stackoverflow.com/questions/47064474/avoid-try-catch-in-numba

yosakabe
Researcher / Qiitaではバグとかエラー解消法を中心に投稿(予定)
http://coffeebreakscript.hatenablog.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした