cbuffer

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cbuffer provides a wrapper for a C/C++ buffer that can be used to transfer data in-between pjrt, xlabuilder and the user of the library.

It is used to feed data: literals for xlabuilder, and actual values for pjrt, and as a holder of the StableHLO program built by xlabuilder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CBuffer

type CBuffer struct {
	// contains filtered or unexported fields
}

CBuffer is a generic wrapper to a C/C++ data, which is assumed to own the underlying data.

func New

func New(data unsafe.Pointer, size int, withStack bool) *CBuffer

New returns a CBuffer object to manage the C/C++ data.

If `withStack` is set to true, it also stores a stack of where it was created. This is used for debugging if it is garbage collected without being freed.

func (*CBuffer) Bytes

func (b *CBuffer) Bytes() []byte

Bytes returns the buffer as a byte slice.

Ownership is not transferred: remember to free CBuffer afterwards.

func (*CBuffer) Free

func (b *CBuffer) Free()

Free underlying data. It sets the pointer to nil, so if it is called again it is a no-op.

Jump to

Keyboard shortcuts

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