utils

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package utils provides shared utilities for GPU Go.

Index

Constants

View Source
const (
	IsolationModeShared      = "shared"
	IsolationModeSoft        = "soft"
	IsolationModePartitioned = "partitioned"
)

IsolationMode constants matching tensor-fusion types

Variables

This section is empty.

Functions

func AtomicWriteFile

func AtomicWriteFile(path string, data []byte, perm os.FileMode) error

AtomicWriteFile writes data to a file atomically by writing to a temp file first and then renaming. This prevents partial writes on failure.

func CheckPortAvailability

func CheckPortAvailability(port int) (int, error)

CheckPortAvailability checks if a port is available. If occupied, returns the PID using it (if resolvable) and an error indicating it's in use. If available, returns 0 and nil.

func FromTFIsolationMode

func FromTFIsolationMode(mode tfv1.IsolationModeType) string

FromTFIsolationMode converts tensor-fusion IsolationModeType to string

func LoadJSON

func LoadJSON[T any](path string) (*T, error)

LoadJSON loads JSON from a file into the provided pointer. Returns nil, nil if file doesn't exist (not an error).

func LoadJSONSlice

func LoadJSONSlice[T any](path string) ([]T, error)

LoadJSONSlice loads a JSON array from a file into a slice. Returns nil, nil if file doesn't exist (not an error).

func SaveJSON

func SaveJSON[T any](path string, data T, perm os.FileMode) error

SaveJSON saves data as JSON to the specified path atomically.

func SaveJSONSlice

func SaveJSONSlice[T any](path string, data []T, perm os.FileMode) error

SaveJSONSlice saves a slice as JSON to the specified path atomically.

func ToTFIsolationMode

func ToTFIsolationMode(s string) tfv1.IsolationModeType

ToTFIsolationMode converts a string to tensor-fusion IsolationModeType

Types

This section is empty.

Jump to

Keyboard shortcuts

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