Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stemann committed Dec 15, 2024
1 parent 074a558 commit 10c7a60
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/device.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ mutable struct Device
mlx_device::Wrapper.mlx_device

function Device(mlx_device::Wrapper.mlx_device)
if mlx_device.ctx == C_NULL # TODO true for Wrapper.mlx_device_new()
throw(MLXException("Cannot create device from a null device"))
end
this = new(mlx_device)
finalizer(d -> Wrapper.mlx_device_free(d.mlx_device), this)
return this
Expand All @@ -19,12 +16,7 @@ end
function Device(; device_type = DeviceTypeCPU, index::Int = 0)
mlx_device_type = Wrapper.mlx_device_type(UInt32(device_type))
mlx_device = Wrapper.mlx_device_new_type(mlx_device_type, index)
try
return Device(mlx_device)
catch
Wrapper.mlx_device_free(mlx_device)
rethrow()
end
return Device(mlx_device)
end

function Base.getproperty(device::Device, name::Symbol)
Expand Down

0 comments on commit 10c7a60

Please sign in to comment.