Skip to content

Commit 30580cb

Browse files
committed
nim 1.x.x compat
1 parent 5f5e75b commit 30580cb

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/arraymancer/tensor/backend/cuda.nim

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,16 @@ type
8888
len*: cint # Number of elements allocated in memory
8989

9090

91-
proc `=destroy`*(p: CudaLayoutArrayObj) {.noSideEffect.}=
92-
if not p.value.isNil:
93-
discard cudaFree(p.value)
91+
when NimMajor == 1:
92+
proc `=destroy`*(p: var CudaLayoutArrayObj) {.noSideEffect.}=
93+
if not p.value.isNil:
94+
discard cudaFree(p.value)
95+
else:
96+
proc `=destroy`*(p: CudaLayoutArrayObj) {.noSideEffect.}=
97+
if not p.value.isNil:
98+
discard cudaFree(p.value)
99+
100+
94101

95102
proc layoutOnDevice*[T:SomeFloat](t: CudaTensor[T]): CudaTensorLayout[T] {.noSideEffect.}=
96103
## Store a CudaTensor shape, strides, etc information on the GPU

src/arraymancer/tensor/data_structure.nim

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,14 @@ type
7979

8080
AnyTensor*[T] = Tensor[T] or CudaTensor[T] or ClTensor[T]
8181

82-
proc `=destroy`*[T](p: CudaTensorRefTrackerObj[T]) {.noSideEffect.}=
83-
if not p.value.isNil:
84-
discard cudaFree(p.value)
82+
when NimMajor == 1:
83+
proc `=destroy`*[T](p: var CudaTensorRefTrackerObj[T]) {.noSideEffect.}=
84+
if not p.value.isNil:
85+
discard cudaFree(p.value)
86+
else:
87+
proc `=destroy`*[T](p: CudaTensorRefTrackerObj[T]) {.noSideEffect.}=
88+
if not p.value.isNil:
89+
discard cudaFree(p.value)
8590

8691

8792

0 commit comments

Comments
 (0)