Return correct value in memory limit getter functions#223
Return correct value in memory limit getter functions#223davidkoski merged 2 commits intoml-explore:mainfrom
Conversation
|
Added |
| public let architecture: String | ||
| public let maxBufferSize: Int | ||
| public let maxRecommendedWorkingSetSize: UInt64 | ||
| public let memorySize: Int |
There was a problem hiding this comment.
I'm curious about that. The internet says these should be public by default. Any idea why they need the public keyword here?
There was a problem hiding this comment.
From the swift-book | Default Access Levels:
All entities in your code (with a few specific exceptions, as described later in this chapter) have a default access level of internal if you don’t specify an explicit access level yourself. As a result, in many cases you don’t need to specify an explicit access level in your code.
And later on in Custom Types
If you define a type’s access level as internal or public (or use the default access level of internal without specifying an access level explicitly), the default access level of the type’s members will be internal.
So in this case the structure is public but, outside of the MLX-swift module itself all its members (implicitly declared as internal) are not accessible.
This PR covers two small bugs in the GPU memory limit related functions
When calling
cacheLimitwithout having previously set any limit, the function would incorrectly report erroneous values (it would report whatever was the current cache value).The logic has been fixed to report the actual value.
When calling
memoryLimit, the value would not get saved to the cached variable, prompting the code to call the C function every time.Finally the link to the metal doc has been updated.