pytorch

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: BSD-2-Clause Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidMagicNumber = errors.New("invalid pytorch magic number")
View Source
var ErrInvalidProtocolVersion = errors.New("invalid pytorch protocol version")

Functions

func FloatBits16to32

func FloatBits16to32(u16 uint16) uint32

FloatBits16to32 converts the bits representation of a Half Float (16 bits) number to an IEEE 754 float representation (32 bits) From http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf

func Load

func Load(filename string) (interface{}, error)

func LoadWithUnpickler

func LoadWithUnpickler(filename string, newUnpickler func(r io.Reader) pickle.Unpickler) (interface{}, error)

LoadWithUnpickler is like Load, but it accepts a newUnpickler function which is used to create new customized pickle.Unpickler instances.

Types

type BFloat16Storage added in v0.2.0

type BFloat16Storage struct {
	BaseStorage
	Data []float32
}

func (*BFloat16Storage) SetFromFile added in v0.2.0

func (f *BFloat16Storage) SetFromFile(r io.Reader) error

func (*BFloat16Storage) SetFromFileWithSize added in v0.2.0

func (f *BFloat16Storage) SetFromFileWithSize(r io.Reader, size int) error

type BFloat16StorageClass added in v0.2.0

type BFloat16StorageClass struct{}

func (*BFloat16StorageClass) New added in v0.2.0

func (f *BFloat16StorageClass) New(size int, location string) StorageInterface

type BaseStorage

type BaseStorage struct {
	Size     int
	Location string
}

type BoolStorage

type BoolStorage struct {
	BaseStorage
	Data []bool
}

func (*BoolStorage) SetFromFile

func (f *BoolStorage) SetFromFile(r io.Reader) error

func (*BoolStorage) SetFromFileWithSize

func (f *BoolStorage) SetFromFileWithSize(r io.Reader, size int) error

type BoolStorageClass

type BoolStorageClass struct{}

func (*BoolStorageClass) New

func (f *BoolStorageClass) New(size int, location string) StorageInterface

type ByteStorage

type ByteStorage struct {
	BaseStorage
	Data []uint8
}

func (*ByteStorage) SetFromFile

func (f *ByteStorage) SetFromFile(r io.Reader) error

func (*ByteStorage) SetFromFileWithSize

func (f *ByteStorage) SetFromFileWithSize(r io.Reader, size int) error

type ByteStorageClass

type ByteStorageClass struct{}

func (*ByteStorageClass) New

func (f *ByteStorageClass) New(size int, location string) StorageInterface

type CharStorage

type CharStorage struct {
	BaseStorage
	Data []int8
}

func (*CharStorage) SetFromFile

func (f *CharStorage) SetFromFile(r io.Reader) error

func (*CharStorage) SetFromFileWithSize

func (f *CharStorage) SetFromFileWithSize(r io.Reader, size int) error

type CharStorageClass

type CharStorageClass struct{}

func (*CharStorageClass) New

func (f *CharStorageClass) New(size int, location string) StorageInterface

type DoubleStorage

type DoubleStorage struct {
	BaseStorage
	Data []float64
}

func (*DoubleStorage) SetFromFile

func (f *DoubleStorage) SetFromFile(r io.Reader) error

func (*DoubleStorage) SetFromFileWithSize

func (f *DoubleStorage) SetFromFileWithSize(r io.Reader, size int) error

type DoubleStorageClass

type DoubleStorageClass struct{}

func (*DoubleStorageClass) New

func (f *DoubleStorageClass) New(size int, location string) StorageInterface

type FloatStorage

type FloatStorage struct {
	BaseStorage
	Data []float32
}

func (*FloatStorage) SetFromFile

func (f *FloatStorage) SetFromFile(r io.Reader) error

func (*FloatStorage) SetFromFileWithSize

func (f *FloatStorage) SetFromFileWithSize(r io.Reader, size int) error

type FloatStorageClass

type FloatStorageClass struct{}

func (*FloatStorageClass) New

func (f *FloatStorageClass) New(size int, location string) StorageInterface

type HalfStorage

type HalfStorage struct {
	BaseStorage
	Data []float32
}

func (*HalfStorage) SetFromFile

func (f *HalfStorage) SetFromFile(r io.Reader) error

func (*HalfStorage) SetFromFileWithSize

func (f *HalfStorage) SetFromFileWithSize(r io.Reader, size int) error

type HalfStorageClass

type HalfStorageClass struct{}

func (*HalfStorageClass) New

func (f *HalfStorageClass) New(size int, location string) StorageInterface

type IntStorage

type IntStorage struct {
	BaseStorage
	Data []int32
}

func (*IntStorage) SetFromFile

func (f *IntStorage) SetFromFile(r io.Reader) error

func (*IntStorage) SetFromFileWithSize

func (f *IntStorage) SetFromFileWithSize(r io.Reader, size int) error

type IntStorageClass

type IntStorageClass struct{}

func (*IntStorageClass) New

func (f *IntStorageClass) New(size int, location string) StorageInterface

type LimitedBufferReader

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

func NewLimitedBufferReader

func NewLimitedBufferReader(
	r io.Reader,
	dataSize, scalarSize, bufferSize int,
) *LimitedBufferReader

func (*LimitedBufferReader) HasNext

func (br *LimitedBufferReader) HasNext() bool

func (*LimitedBufferReader) ReadNext

func (br *LimitedBufferReader) ReadNext() ([]byte, error)

type LongStorage

type LongStorage struct {
	BaseStorage
	Data []int64
}

func (*LongStorage) SetFromFile

func (f *LongStorage) SetFromFile(r io.Reader) error

func (*LongStorage) SetFromFileWithSize

func (f *LongStorage) SetFromFileWithSize(r io.Reader, size int) error

type LongStorageClass

type LongStorageClass struct{}

func (*LongStorageClass) New

func (f *LongStorageClass) New(size int, location string) StorageInterface

type RebuildTensorV2

type RebuildTensorV2 struct{}

func (*RebuildTensorV2) Call

func (r *RebuildTensorV2) Call(args ...interface{}) (interface{}, error)

type ShortStorage

type ShortStorage struct {
	BaseStorage
	Data []int16
}

func (*ShortStorage) SetFromFile

func (f *ShortStorage) SetFromFile(r io.Reader) error

func (*ShortStorage) SetFromFileWithSize

func (f *ShortStorage) SetFromFileWithSize(r io.Reader, size int) error

type ShortStorageClass

type ShortStorageClass struct{}

func (*ShortStorageClass) New

func (f *ShortStorageClass) New(size int, location string) StorageInterface

type StorageClassInterface

type StorageClassInterface interface {
	New(size int, location string) StorageInterface
}

type StorageInterface

type StorageInterface interface {
	SetFromFile(r io.Reader) error
	SetFromFileWithSize(r io.Reader, size int) error
}

type Tensor

type Tensor struct {
	Source        StorageInterface
	StorageOffset int
	Size          []int
	Stride        []int
	RequiresGrad  bool
}

Jump to

Keyboard shortcuts

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