cerebras.elf.cself module

API for cself-related functions

class cerebras.elf.cself.ELFLoader(elf_file: Optional[Union[pathlib.Path, str]] = None, core_file: Optional[Union[pathlib.Path, str]] = None)

Bases: object

A convenience wrapper for ELF files.

Wraps ELFObjects for an executable and a core ELF files.

get_as_array(sym_name: str, local_shape: Union[int, List[int]], sym_type: numpy.dtype) numpy.ndarray

Get the symbol value as a numpy array.

The symbol is assumed to have the numpy type sym_type, and the shape local_shape on each of the PEs. The shape of the array returned is [sz_x, sz_y, *local_shape], where [sz_x, sz_y] is the shape of the (sub-)kernel where the symbol is distributed.

get_as_array_from(column: int, row: int, sym_name: str, sym_type: numpy.dtype) numpy.ndarray

Get the symbol value as a numpy array.

Parameters: column (int): column index of PE from which to read memory row (int): row index of PE from which to read memory sym_name (str): name of symbol on PE sym_type (dtype): base type of data at symbol. e.g. if the symbol

points to an array of int16, this should be np.int16

Returns: np.darray: the data for sym_name on PE (column, row)

get_symbol_addr(sym_name: str) int

Get the byte address for a symbol.

get_symbol_segment(sym_name: str) cerebras.elf.cself.Segment

Get the segment in the core file which contains the symbol.

print_segments()

Print the segments contained in the core file.

set_core(core_file: Union[pathlib.Path, str])

Set the core file.

set_elf(elf_file: Union[pathlib.Path, str])

Set the elf file used to determine symbol addresses.

class cerebras.elf.cself.ELFMemory(elf_file: Union[pathlib.Path, str])

Bases: object

A wrapper for inspecting the memory of a “loaded” ELF file.

get(addr: int) cerebras.elf.cself.Segment

Return the segments containing addr, or [] if addr not present.

get_fabric_dimensions() Tuple[int, int]

Return the fabric dimensions stored in the ELFObject.

iter_coordinates() Generator[Tuple[int, int], None, None]

Iterate over all PE coordinates loaded to by this ELF.

Unlike iter_rectangles, iteration order is in lexical order and contains no duplicates.

iter_rectangles() Generator[cerebras.elf.cself.RectangleDescriptor, None, None]

Iterate over all PE rectangles loaded to by this ELF.

Iteration order is unspecified and duplicates may occur.

class cerebras.elf.cself.RectangleDescriptor(logical_x, logical_y, width, height)

Bases: tuple

property height

Alias for field number 3

property logical_x

Alias for field number 0

property logical_y

Alias for field number 1

property width

Alias for field number 2

class cerebras.elf.cself.Segment(addr, extent, mem_size, data_size, delta, data)

Bases: tuple

property addr

Alias for field number 0

property data

Alias for field number 5

property data_size

Alias for field number 3

property delta

Alias for field number 4

property extent

Alias for field number 1

property mem_size

Alias for field number 2

class cerebras.elf.cself.Symbol(addr, size)

Bases: tuple

property addr

Alias for field number 0

property size

Alias for field number 1