Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to minver in ObjectiveC.jl #513

Merged
merged 6 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ KernelAbstractions = "0.9.1"
LLVM = "7.2, 8, 9"
LLVMDowngrader_jll = "0.6"
LinearAlgebra = "1"
ObjectiveC = "2.1, 3"
ObjectiveC = "3.2"
PrecompileTools = "1"
Preferences = "1"
Printf = "1"
Expand Down
31 changes: 11 additions & 20 deletions lib/mps/ndarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,20 @@ export MPSNDArray

@objcwrapper immutable=false MPSNDArray <: NSObject

@static if Metal.is_macos(v"15")
@objcproperties MPSNDArray begin
@autoproperty dataType::MPSDataType
@autoproperty dataTypeSize::Csize_t
@autoproperty device::id{MTLDevice}
@autoproperty label::id{NSString} setter=setLabel
@autoproperty numberOfDimensions::NSUInteger
@autoproperty parent::id{MPSNDArray}

#Instance methods that act like properties
@objcproperties MPSNDArray begin
@autoproperty dataType::MPSDataType
@autoproperty dataTypeSize::Csize_t
@autoproperty device::id{MTLDevice}
@autoproperty label::id{NSString} setter = setLabel
@autoproperty numberOfDimensions::NSUInteger
@autoproperty parent::id{MPSNDArray}

#Instance methods that act like properties
@static if Metal.is_macos(v"15")
@autoproperty descriptor::id{MPSNDArrayDescriptor}
@autoproperty resourceSize::NSUInteger
@autoproperty userBuffer::id{MTLBuffer}
end
else
@objcproperties MPSNDArray begin
@autoproperty dataType::MPSDataType
@autoproperty dataTypeSize::Csize_t
@autoproperty device::id{MTLDevice}
@autoproperty label::id{NSString} setter=setLabel
@autoproperty numberOfDimensions::NSUInteger
@autoproperty parent::id{MPSNDArray}
end
end

function Base.size(ndarr::MPSNDArray)
Expand Down Expand Up @@ -134,7 +125,7 @@ end

function MPSNDArray(arr::MtlArray{T,N}) where {T,N}
arrsize = size(arr)
@assert arrsize[1]*sizeof(T) % 16 == 0 "First dimension of arr must have a byte size divisible by 16"
@assert arrsize[1] * sizeof(T) % 16 == 0 "First dimension of input MtlArray must have a byte size divisible by 16"
desc = MPSNDArrayDescriptor(T, arrsize)
return MPSNDArray(arr.data[], UInt(arr.offset), desc)
end
Expand Down
6 changes: 5 additions & 1 deletion lib/mtl/device.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export MTLDevice, MTLCreateSystemDefaultDevice, devices
@objcwrapper MTLArchitecture <: NSObject

@objcproperties MTLArchitecture begin
@autoproperty architecture::id{NSString}
@autoproperty name::id{NSString}
end
end

Expand Down Expand Up @@ -56,6 +56,10 @@ end
@autoproperty peerCount::UInt64
@autoproperty peerIndex::UInt64

@static if Metal.is_macos(v"14")
@autoproperty architecture::id{MTLArchitecture}
end

## resource creation
# creating buffers
@autoproperty maxBufferLength::NSUInteger
Expand Down
2 changes: 1 addition & 1 deletion test/mps/ndarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ using .MPS: MPSNDArray
@test ndarr2.parent === nothing

arr3 = MtlArray(ones(Float16, 2,3,4))
@test_throws "First dimension of arr must have a byte size divisible by 16" MPSNDArray(arr3)
@test_throws "First dimension of input MtlArray must have a byte size divisible by 16" MPSNDArray(arr3)

arr4 = MtlArray(ones(Float16, 8,3,2))

Expand Down
Loading