Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
093665d9
提交
093665d9
authored
11月 30, 2022
作者:
Adrian Seyboldt
提交者:
Adrian Seyboldt
12月 02, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix None in slice for numba boxing
上级
0f867394
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
28 行增加
和
5 行删除
+28
-5
basic.py
pytensor/link/numba/dispatch/basic.py
+28
-5
没有找到文件。
pytensor/link/numba/dispatch/basic.py
浏览文件 @
093665d9
import
operator
import
operator
import
sys
import
warnings
import
warnings
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
functools
import
singledispatch
from
functools
import
singledispatch
...
@@ -10,7 +11,7 @@ import numba.np.unsafe.ndarray as numba_ndarray
...
@@ -10,7 +11,7 @@ import numba.np.unsafe.ndarray as numba_ndarray
import
numpy
as
np
import
numpy
as
np
import
scipy
import
scipy
import
scipy.special
import
scipy.special
from
llvmlite
.ir
import
Type
as
llvm_Type
from
llvmlite
import
ir
from
numba
import
types
from
numba
import
types
from
numba.core.errors
import
TypingError
from
numba.core.errors
import
TypingError
from
numba.cpython.unsafe.tuple
import
tuple_setitem
# noqa: F401
from
numba.cpython.unsafe.tuple
import
tuple_setitem
# noqa: F401
...
@@ -131,7 +132,7 @@ def create_numba_signature(
...
@@ -131,7 +132,7 @@ def create_numba_signature(
def
slice_new
(
self
,
start
,
stop
,
step
):
def
slice_new
(
self
,
start
,
stop
,
step
):
fnty
=
llvm_Type
.
function
(
self
.
pyobj
,
[
self
.
pyobj
,
self
.
pyobj
,
self
.
pyobj
])
fnty
=
ir
.
FunctionType
(
self
.
pyobj
,
[
self
.
pyobj
,
self
.
pyobj
,
self
.
pyobj
])
fn
=
self
.
_get_function
(
fnty
,
name
=
"PySlice_New"
)
fn
=
self
.
_get_function
(
fnty
,
name
=
"PySlice_New"
)
return
self
.
builder
.
call
(
fn
,
[
start
,
stop
,
step
])
return
self
.
builder
.
call
(
fn
,
[
start
,
stop
,
step
])
...
@@ -150,11 +151,33 @@ def enable_slice_boxing():
...
@@ -150,11 +151,33 @@ def enable_slice_boxing():
This makes it possible to return an Numba's internal representation of a
This makes it possible to return an Numba's internal representation of a
``slice`` object as a proper ``slice`` to Python.
``slice`` object as a proper ``slice`` to Python.
"""
"""
start
=
c
.
builder
.
extract_value
(
val
,
0
)
stop
=
c
.
builder
.
extract_value
(
val
,
1
)
none_val
=
ir
.
Constant
(
ir
.
IntType
(
64
),
sys
.
maxsize
)
start_is_none
=
c
.
builder
.
icmp_signed
(
"=="
,
start
,
none_val
)
start
=
c
.
builder
.
select
(
start_is_none
,
c
.
pyapi
.
get_null_object
(),
c
.
box
(
types
.
int64
,
start
),
)
stop_is_none
=
c
.
builder
.
icmp_signed
(
"=="
,
stop
,
none_val
)
stop
=
c
.
builder
.
select
(
stop_is_none
,
c
.
pyapi
.
get_null_object
(),
c
.
box
(
types
.
int64
,
stop
),
)
start
=
c
.
box
(
types
.
int64
,
c
.
builder
.
extract_value
(
val
,
0
))
stop
=
c
.
box
(
types
.
int64
,
c
.
builder
.
extract_value
(
val
,
1
))
if
typ
.
has_step
:
if
typ
.
has_step
:
step
=
c
.
box
(
types
.
int64
,
c
.
builder
.
extract_value
(
val
,
2
))
step
=
c
.
builder
.
extract_value
(
val
,
2
)
step_is_none
=
c
.
builder
.
icmp_signed
(
"=="
,
step
,
none_val
)
step
=
c
.
builder
.
select
(
step_is_none
,
c
.
pyapi
.
get_null_object
(),
c
.
box
(
types
.
int64
,
step
),
)
else
:
else
:
step
=
c
.
pyapi
.
get_null_object
()
step
=
c
.
pyapi
.
get_null_object
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论