Skip to content

Commit

Permalink
Merge pull request #7349 from colemanliyah:cache_size_change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 386117870
  • Loading branch information
jax authors committed Jul 21, 2021
2 parents 93a20ee + 86985fd commit fba32c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions jax/experimental/compilation_cache/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
9 changes: 6 additions & 3 deletions jax/experimental/compilation_cache/compilation_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@

_cache = None

def initialize_cache(path):
"""Creates a global cache object. Should only be called once per process."""
def initialize_cache(path, max_cache_size_bytes=32 * 2**30):
"""Creates a global cache object. Should only be called once per process.
max_cache_sixe defaults to 32GiB.
"""
global _cache
assert _cache == None, f"The cache path has already been initialized to {_cache}"
_cache = FileSystemCache(path)
_cache = FileSystemCache(path, max_cache_size_bytes)

def get_executable(xla_computation, compile_options) -> Optional[xla_client.Executable]:
"""Returns the cached executable if present, or None otherwise."""
Expand Down

0 comments on commit fba32c3

Please sign in to comment.