Documentation ¶
Index ¶
- Constants
- Variables
- func CachedPath(filenameOrUrl string, folderOpt ...string) (resolvedPath string, err error)
- func CleanCache() error
- func IsFloatDType(dtype DType) bool
- func PrintMemStats(messageOpt ...string)
- type CInt
- type Cuda
- type DType
- type DTypeDevice
- type DTypeOpt
- type DTypeOptions
- type Device
Constants ¶
const ( // NOTE. reflect.Kind 0-26 QUInt8Kind reflect.Kind = 27 QInt8Kind reflect.Kind = 28 QInt32Kind reflect.Kind = 29 Float16Kind reflect.Kind = 30 BFloat16Kind reflect.Kind = 31 QUInt4x2Kind reflect.Kind = 32 QUInt2x4Kind reflect.Kind = 33 Bits1x8Kind reflect.Kind = 34 Bits2x4Kind reflect.Kind = 35 Bits4x2Kind reflect.Kind = 36 Bits8Kind reflect.Kind = 37 Bits16Kind reflect.Kind = 38 ComplexHalfKind reflect.Kind = 39 )
Variables ¶
var ( CPU Device = Device{Name: "CPU", Value: -1} CUDA Cuda = Cuda{Name: "CUDA", Value: 0} )
var ( CachedDir string = "NOT_SETTING" Debug bool = false )
var ModelUrls map[string]string = map[string]string{
"alexnet": "https://download.pytorch.org/models/alexnet-owt-7be5be79.pth",
"convnext_tiny": "https://download.pytorch.org/models/convnext_tiny-983f1562.pth",
"convnext_small": "https://download.pytorch.org/models/convnext_small-0c510722.pth",
"convnext_base": "https://download.pytorch.org/models/convnext_base-6075fbad.pth",
"convnext_large": "https://download.pytorch.org/models/convnext_large-ea097f82.pth",
"densenet121": "https://download.pytorch.org/models/densenet121-a639ec97.pth",
"densenet169": "https://download.pytorch.org/models/densenet169-b2777c0a.pth",
"densenet201": "https://download.pytorch.org/models/densenet201-c1103571.pth",
"densenet161": "https://download.pytorch.org/models/densenet161-8d451a50.pth",
"efficientnet_b0": "https://download.pytorch.org/models/efficientnet_b0_rwightman-3dd342df.pth",
"efficientnet_b1": "https://download.pytorch.org/models/efficientnet_b1_rwightman-533bc792.pth",
"efficientnet_b2": "https://download.pytorch.org/models/efficientnet_b2_rwightman-bcdf34b7.pth",
"efficientnet_b3": "https://download.pytorch.org/models/efficientnet_b3_rwightman-cf984f9c.pth",
"efficientnet_b4": "https://download.pytorch.org/models/efficientnet_b4_rwightman-7eb33cd5.pth",
"efficientnet_b5": "https://download.pytorch.org/models/efficientnet_b5_lukemelas-b6417697.pth",
"efficientnet_b6": "https://download.pytorch.org/models/efficientnet_b6_lukemelas-c76e70fd.pth",
"efficientnet_b7": "https://download.pytorch.org/models/efficientnet_b7_lukemelas-dcc49843.pth",
"googlenet": "https://download.pytorch.org/models/googlenet-1378be20.pth",
"inception_v3_google": "https://download.pytorch.org/models/inception_v3_google-0cc3c7bd.pth",
"mnasnet0_5": "https://download.pytorch.org/models/mnasnet0.5_top1_67.823-3ffadce67e.pth",
"mnasnet0_75": "",
"mnasnet1_0": "https://download.pytorch.org/models/mnasnet1.0_top1_73.512-f206786ef8.pth",
"mnasnet1_3": "",
"mobilenet_v2": "https://download.pytorch.org/models/mobilenet_v2-b0353104.pth",
"mobilenet_v3_large": "https://download.pytorch.org/models/mobilenet_v3_large-8738ca79.pth",
"mobilenet_v3_small": "https://download.pytorch.org/models/mobilenet_v3_small-047dcff4.pth",
"regnet_y_400mf": "https://download.pytorch.org/models/regnet_y_400mf-c65dace8.pth",
"regnet_y_800mf": "https://download.pytorch.org/models/regnet_y_800mf-1b27b58c.pth",
"regnet_y_1_6gf": "https://download.pytorch.org/models/regnet_y_1_6gf-b11a554e.pth",
"regnet_y_3_2gf": "https://download.pytorch.org/models/regnet_y_3_2gf-b5a9779c.pth",
"regnet_y_8gf": "https://download.pytorch.org/models/regnet_y_8gf-d0d0e4a8.pth",
"regnet_y_16gf": "https://download.pytorch.org/models/regnet_y_16gf-9e6ed7dd.pth",
"regnet_y_32gf": "https://download.pytorch.org/models/regnet_y_32gf-4dee3f7a.pth",
"regnet_x_400mf": "https://download.pytorch.org/models/regnet_x_400mf-adf1edd5.pth",
"regnet_x_800mf": "https://download.pytorch.org/models/regnet_x_800mf-ad17e45c.pth",
"regnet_x_1_6gf": "https://download.pytorch.org/models/regnet_x_1_6gf-e3633e7f.pth",
"regnet_x_3_2gf": "https://download.pytorch.org/models/regnet_x_3_2gf-f342aeae.pth",
"regnet_x_8gf": "https://download.pytorch.org/models/regnet_x_8gf-03ceed89.pth",
"regnet_x_16gf": "https://download.pytorch.org/models/regnet_x_16gf-2007eb11.pth",
"regnet_x_32gf": "https://download.pytorch.org/models/regnet_x_32gf-9d47f8d0.pth",
"resnet18": "https://download.pytorch.org/models/resnet18-f37072fd.pth",
"resnet34": "https://download.pytorch.org/models/resnet34-b627a593.pth",
"resnet50": "https://download.pytorch.org/models/resnet50-0676ba61.pth",
"resnet101": "https://download.pytorch.org/models/resnet101-63fe2227.pth",
"resnet152": "https://download.pytorch.org/models/resnet152-394f9c45.pth",
"resnext50_32x4d": "https://download.pytorch.org/models/resnext50_32x4d-7cdf4587.pth",
"resnext101_32x8d": "https://download.pytorch.org/models/resnext101_32x8d-8ba56ff5.pth",
"wide_resnet50_2": "https://download.pytorch.org/models/wide_resnet50_2-95faca4d.pth",
"wide_resnet101_2": "https://download.pytorch.org/models/wide_resnet101_2-32ee1156.pth",
"shufflenetv2_x0.5": "https://download.pytorch.org/models/shufflenetv2_x0.5-f707e7126e.pth",
"shufflenetv2_x1.0": "https://download.pytorch.org/models/shufflenetv2_x1-5666bf0f80.pth",
"shufflenetv2_x1.5": "",
"shufflenetv2_x2.0": "",
"squeezenet1_0": "https://download.pytorch.org/models/squeezenet1_0-b66bff10.pth",
"squeezenet1_1": "https://download.pytorch.org/models/squeezenet1_1-b8a52dc0.pth",
"vgg11": "https://download.pytorch.org/models/vgg11-8a719046.pth",
"vgg13": "https://download.pytorch.org/models/vgg13-19584684.pth",
"vgg16": "https://download.pytorch.org/models/vgg16-397923af.pth",
"vgg19": "https://download.pytorch.org/models/vgg19-dcbb9e9d.pth",
"vgg11_bn": "https://download.pytorch.org/models/vgg11_bn-6002323d.pth",
"vgg13_bn": "https://download.pytorch.org/models/vgg13_bn-abd245e5.pth",
"vgg16_bn": "https://download.pytorch.org/models/vgg16_bn-6c64b313.pth",
"vgg19_bn": "https://download.pytorch.org/models/vgg19_bn-c79401a0.pth",
"vit_b_16": "https://download.pytorch.org/models/vit_b_16-c867db91.pth",
"vit_b_32": "https://download.pytorch.org/models/vit_b_32-d86f8d99.pth",
"vit_l_16": "https://download.pytorch.org/models/vit_l_16-852ce7e3.pth",
"vit_l_32": "https://download.pytorch.org/models/vit_l_32-c7638314.pth",
}
ModelUrls maps model name to its pretrained URL.
This URLS taken from separate models in pytorch/vision repository https://github.com/pytorch/vision/tree/main/torchvision/models
Functions ¶
func CachedPath ¶ added in v0.6.0
CachedPath resolves and caches data based on input string, then returns fullpath to the cached data.
Parameters: - `filenameOrUrl`: full path to filename or url
CachedPath does several things consequently: 1. Resolves input string to a fullpath cached filename candidate. 2. Check it at `CachedDir`, if exists, then return the candidate. If not 3. Retrieves and Caches data to `CachedDir` and returns path to cached data
func CleanCache ¶ added in v0.6.2
func CleanCache() error
CleanCache removes all files cached at `CachedDir`
func IsFloatDType ¶ added in v0.8.0
IsFloatDType returns whether dtype is floating point data type.
func PrintMemStats ¶ added in v0.8.0
func PrintMemStats(messageOpt ...string)
Types ¶
type Cuda ¶
type Cuda Device
func (Cuda) CudnnIsAvailable ¶
CudnnIsAvailable return true if cudnn support is available
func (Cuda) CudnnSetBenchmark ¶
CudnnSetBenchmark sets cudnn benchmark mode
When set cudnn will try to optimize the generators during the first network runs and then use the optimized architecture in the following runs. This can result in significant performance improvements.
func (Cuda) DeviceCount ¶
DeviceCount returns the number of GPU that can be used.
func (Cuda) IsAvailable ¶
CudnnIsAvailable returns true if cuda support is available
type DType ¶
type DType int
DType represents different kind of element that a tensor can hold. Ref. https://github.com/pytorch/pytorch/blob/a290cbf32b0c282aa60fa521ca5c6cd19c7f779f/c10/core/ScalarType.h
const ( Invalid DType = -1 Uint8 DType = 0 Int8 DType = 1 Int16 DType = 2 Int DType = 3 Int64 DType = 4 Half DType = 5 Float DType = 6 Double DType = 7 ComplexHalf DType = 8 ComplexFloat DType = 9 ComplexDouble DType = 10 Bool DType = 11 QInt8 DType = 12 QUInt8 DType = 13 QInt32 DType = 14 BFloat16 DType = 15 // ---not implemented --- QUInt4x2 DType = 16 QUInt2x4 DType = 17 Bits1x8 DType = 18 Bits2x4 DType = 19 Bits4x2 DType = 20 Bits8 DType = 21 Bits16 DType = 22 )
func CKind2DType ¶ added in v0.8.0
func DTypeFromData ¶
func GoKind2DType ¶ added in v0.8.0
func SetDefaultDType ¶ added in v0.8.0
SetDefaultDType set DefaultDType to new value and return the previous one.
type DTypeDevice ¶
var ( FloatCPU DTypeDevice = DTypeDevice{Float, CPU} DoubleCPU DTypeDevice = DTypeDevice{Double, CPU} Int64CPU DTypeDevice = DTypeDevice{Int64, CPU} FloatCUDA DTypeDevice = DTypeDevice{Float, CudaBuilder(0)} DoubleCUDA DTypeDevice = DTypeDevice{Double, CudaBuilder(0)} Int64CUDA DTypeDevice = DTypeDevice{Int64, CudaBuilder(0)} )
type DTypeOpt ¶ added in v0.8.0
type DTypeOpt func(*DTypeOptions)
func HalfDTypePref ¶ added in v0.8.0
func WithQuantized ¶ added in v0.8.0
type DTypeOptions ¶ added in v0.8.0
func DefaultDTypeOptions ¶ added in v0.8.0
func DefaultDTypeOptions() *DTypeOptions
type Device ¶
func CudaBuilder ¶
func CudaIfAvailable ¶ added in v0.3.5
func CudaIfAvailable() Device
CudaIfAvailable returns a GPU device if available, else CPU.
func NewCuda ¶
func NewCuda() Device
NewCuda creates a cuda device (default) if available If will be panic if cuda is not available.
func (Device) CudaIfAvailable ¶
CudaIfAvailable returns a GPU device if available, else default to CPU
Directories ¶
Path | Synopsis |
---|---|
example
|
|
yolo/freetype
The freetype package provides a convenient API to draw text onto an image.
|
The freetype package provides a convenient API to draw text onto an image. |
Package half defines support for half-precision floating-point numbers.
|
Package half defines support for half-precision floating-point numbers. |
NOTE: functions in this file would be automatically generated and named as `c-generated.go`
|
NOTE: functions in this file would be automatically generated and named as `c-generated.go` |