-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix offsetarrays support * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * add test file --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ce20b3c
commit 0e764de
Showing
6 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module ReactantOffsetArraysExt | ||
|
||
using OffsetArrays: OffsetArray | ||
using Reactant: Reactant, MLIR, Ops, TracedRArray | ||
|
||
function Reactant.traced_type( | ||
::Type{<:OffsetArray{<:Any,N,T}}, seen::ST, ::Val{mode}, track_numbers | ||
) where {T,N,ST,mode} | ||
T2 = Reactant.traced_type(T, seen, Val(mode), track_numbers) | ||
return OffsetArray{eltype(T2),N,T2} | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Reactant | ||
using Test | ||
using OffsetArrays | ||
|
||
function scalar_index(x) | ||
@allowscalar getindex(x, -1, 0) | ||
end | ||
@testset "OffsetArrays" begin | ||
A = Float64.(reshape(1:15, 3, 5)) | ||
OA = OffsetArray(A, -1:1, 0:4) | ||
rOA = Reactant.to_rarray(OA) | ||
|
||
oval = scalar_index(OA) | ||
cval = scalar_index(rOA) | ||
@test cval ≈ oval | ||
|
||
tval = @jit scalar_index(rOA) | ||
@test tval ≈ oval | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters