utils

package
v0.4.38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package utils holds small utility types and functions used internally in stablehlo.

Index

Constants

This section is empty.

Variables

View Source
var DefaultCPUVersion = "v0.117.2"

DefaultCPUVersion is the default version of the CPU PJRT plugin to use with this go-xla release, against which it was tested. Exported in pkg/pjrt, but a copy is kept here, so `pkg/installer` can include it without pulling the whole of PJRT.

Functions

func DTypeToStableHLO

func DTypeToStableHLO(dtype dtypes.DType) string

DTypeToStableHLO returns the StableHLO string representation of the DType.

func NormalizeIdentifier

func NormalizeIdentifier(name string) string

NormalizeIdentifier converts the name of an identifier (function name or function input parameter name) to a valid one: only letters, digits, and underscores are allowed.

Invalid characters are replaced with underscores. If the name starts with a digit, it is prefixed with an underscore.

func SortedKeys

func SortedKeys[T cmp.Ordered](set Set[T]) []T

SortedKeys returns the keys of the set in sorted order.

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase converts a string from CamelCase to snake_case.

Types

type Set

type Set[T comparable] map[T]struct{}

Set implements a Set for the key type T.

func MakeSet

func MakeSet[T comparable](size ...int) Set[T]

MakeSet returns an empty Set of the given type. Size is optional, and if given will reserve the expected size.

func SetWith

func SetWith[T comparable](elements ...T) Set[T]

SetWith creates a Set[T] with the given elements inserted.

func (Set[T]) Add

func (s Set[T]) Add(s2 Set[T]) Set[T]

Add returns the union of s and s2.

func (Set[T]) Clone

func (s Set[T]) Clone() Set[T]

Clone returns a copy of the set.

func (Set[T]) Equal

func (s Set[T]) Equal(s2 Set[T]) bool

Equal returns whether s and s2 have the exact same elements.

func (Set[T]) Has

func (s Set[T]) Has(key T) bool

Has returns true if Set s has the given key.

func (Set[T]) Insert

func (s Set[T]) Insert(keys ...T)

Insert keys into set.

func (Set[T]) Sub

func (s Set[T]) Sub(s2 Set[T]) Set[T]

Sub returns s - s2, that is, all elements in `s` that are not in `s2`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL