Skip to content

Commit cce51ce

Browse files
authored
Small fix for missing allocation_size implementation (#253)
* add missing method for dealing with single integer * bump v5.5.1 * make sure function is covered
1 parent 309e152 commit cce51ce

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "TensorOperations"
22
uuid = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
3-
version = "5.5.0"
3+
version = "5.5.1"
44
authors = ["Lukas Devos <lukas.devos@ugent.be>", "Maarten Van Damme <maartenvd1994@gmail.com>", "Jutho Haegeman <jutho.haegeman@ugent.be>"]
55

66
[deps]

src/implementation/allocator.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ end
258258

259259
# how many bytes should be reserved
260260
allocation_size(::Type{T}, structure::Base.Dims) where {T} = prod(structure) * sizeof(T)
261+
allocation_size(::Type{T}, structure::Int) where {T} = structure * sizeof(T)
261262

262263
function tensoralloc(
263264
::Type{A}, structure, ::Val{istemp}, buffer::BufferAllocator

test/allocator.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ using LinearAlgebra
5959
@test cp0 == 0
6060

6161
# Allocate some tensors
62-
t1 = tensoralloc(Array{UInt8, 2}, (10, 10), Val(true), buffer) # should fit
63-
@test t1 isa Array{UInt8, 2}
64-
@test size(t1) == (10, 10)
62+
t1 = tensoralloc(Vector{UInt8}, 100, Val(true), buffer) # should fit
63+
@test t1 isa Vector{UInt8}
64+
@test size(t1) == (100,)
6565
cp1 = allocator_checkpoint!(buffer)
6666
@test cp1 > cp0
6767
# Verify pointer backing from buffer

0 commit comments

Comments
 (0)