rocm.hipfile.file#

2026-09-24

4 min read time

Applies to Linux and Windows

Advanced Micro Devices, Inc.

Classes#

FileHandle

Lifecycle manager for a hipFile-registered open file.

Module Contents#

class rocm.hipfile.file.FileHandle(path, flags, mode=DEFAULT_MODE, handle_type=FileHandleType.OPAQUE_FD)#

Lifecycle manager for a hipFile-registered open file.

Wraps hipFileHandleRegister / hipFileHandleDeregister plus synchronous hipFileRead / hipFileWrite.

Use as a context manager:

with FileHandle(path, os.O_RDWR | os.O_DIRECT) as fh:

fh.read(buf, size, file_offset, buffer_offset) fh.write(buf, size, file_offset, buffer_offset)

DEFAULT_MODE = 420#
property handle_type#
property flags#
property handle#
property mode#
property path#
open()#
close()#
read(buffer, size, file_offset, buffer_offset)#

Synchronous read into a registered Buffer.

Returns the number of bytes read on success. Raises HipFileException (with the parsed OpError and HIP driver error) on a hipFile-level error, or OSError (with the real errno) on a POSIX-level error.

write(buffer, size, file_offset, buffer_offset)#

Synchronous write from a registered Buffer.

Returns the number of bytes written on success. Same error semantics as read.