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

[PJRT][IFRT] Update PJRT, IFRT, and Py executable getters to return PjRtLayouts #20240

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 11 additions & 2 deletions jax/_src/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

from __future__ import annotations
import re

from jax._src.lib import xla_client as xc

Expand All @@ -33,8 +34,7 @@ class SpecifiedLayout(XLACompatibleLayout):

def __init__(self, layout: xc.Layout):
self._layout = layout
self._layout_str = self._layout.to_string()
self._minor_to_major = self._layout.minor_to_major()
self._layout_str = str(self._layout)

def __repr__(self):
return f'SpecifiedLayout({self._layout_str})'
Expand All @@ -50,6 +50,15 @@ def __eq__(self, other):
def _to_xla_layout(self) -> str:
return self._layout_str

@property
def _minor_to_major(self):
m = re.search("{([0-9,]*):", str(self))
assert m is not None
m2m_str = m.group(1)
if m2m_str == '':
return ()
return tuple(int(x) for x in m2m_str.split(","))


class LayoutRequest:

Expand Down