id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5,400 | dinever/golf | app.go | Run | func (app *Application) Run(addr string) {
err := http.ListenAndServe(addr, app)
if err != nil {
panic(err)
}
} | go | func (app *Application) Run(addr string) {
err := http.ListenAndServe(addr, app)
if err != nil {
panic(err)
}
} | [
"func",
"(",
"app",
"*",
"Application",
")",
"Run",
"(",
"addr",
"string",
")",
"{",
"err",
":=",
"http",
".",
"ListenAndServe",
"(",
"addr",
",",
"app",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"}"
] | // Run the Golf Application. | [
"Run",
"the",
"Golf",
"Application",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/app.go#L113-L118 |
5,401 | dinever/golf | app.go | RunTLS | func (app *Application) RunTLS(addr, certFile, keyFile string) {
err := http.ListenAndServeTLS(addr, certFile, keyFile, app)
if err != nil {
panic(err)
}
} | go | func (app *Application) RunTLS(addr, certFile, keyFile string) {
err := http.ListenAndServeTLS(addr, certFile, keyFile, app)
if err != nil {
panic(err)
}
} | [
"func",
"(",
"app",
"*",
"Application",
")",
"RunTLS",
"(",
"addr",
",",
"certFile",
",",
"keyFile",
"string",
")",
"{",
"err",
":=",
"http",
".",
"ListenAndServeTLS",
"(",
"addr",
",",
"certFile",
",",
"keyFile",
",",
"app",
")",
"\n",
"if",
"err",
... | // RunTLS runs the app with TLS support. | [
"RunTLS",
"runs",
"the",
"app",
"with",
"TLS",
"support",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/app.go#L121-L126 |
5,402 | dinever/golf | app.go | Static | func (app *Application) Static(url string, path string) {
url = strings.TrimRight(url, "/")
app.staticRouter[url] = append(app.staticRouter[url], path)
} | go | func (app *Application) Static(url string, path string) {
url = strings.TrimRight(url, "/")
app.staticRouter[url] = append(app.staticRouter[url], path)
} | [
"func",
"(",
"app",
"*",
"Application",
")",
"Static",
"(",
"url",
"string",
",",
"path",
"string",
")",
"{",
"url",
"=",
"strings",
".",
"TrimRight",
"(",
"url",
",",
"\"",
"\"",
")",
"\n",
"app",
".",
"staticRouter",
"[",
"url",
"]",
"=",
"append... | // Static is used for registering a static folder | [
"Static",
"is",
"used",
"for",
"registering",
"a",
"static",
"folder"
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/app.go#L129-L132 |
5,403 | dinever/golf | app.go | Get | func (app *Application) Get(pattern string, handler HandlerFunc) {
app.router.AddRoute("GET", pattern, handler)
} | go | func (app *Application) Get(pattern string, handler HandlerFunc) {
app.router.AddRoute("GET", pattern, handler)
} | [
"func",
"(",
"app",
"*",
"Application",
")",
"Get",
"(",
"pattern",
"string",
",",
"handler",
"HandlerFunc",
")",
"{",
"app",
".",
"router",
".",
"AddRoute",
"(",
"\"",
"\"",
",",
"pattern",
",",
"handler",
")",
"\n",
"}"
] | // Get method is used for registering a Get method route | [
"Get",
"method",
"is",
"used",
"for",
"registering",
"a",
"Get",
"method",
"route"
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/app.go#L135-L137 |
5,404 | dinever/golf | app.go | Error | func (app *Application) Error(statusCode int, handler ErrorHandlerFunc) {
app.errorHandler[statusCode] = handler
} | go | func (app *Application) Error(statusCode int, handler ErrorHandlerFunc) {
app.errorHandler[statusCode] = handler
} | [
"func",
"(",
"app",
"*",
"Application",
")",
"Error",
"(",
"statusCode",
"int",
",",
"handler",
"ErrorHandlerFunc",
")",
"{",
"app",
".",
"errorHandler",
"[",
"statusCode",
"]",
"=",
"handler",
"\n",
"}"
] | // Error method is used for registering an handler for a specified HTTP error code. | [
"Error",
"method",
"is",
"used",
"for",
"registering",
"an",
"handler",
"for",
"a",
"specified",
"HTTP",
"error",
"code",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/app.go#L170-L172 |
5,405 | dinever/golf | app.go | handleError | func (app *Application) handleError(ctx *Context, statusCode int, data ...map[string]interface{}) {
ctx.SendStatus(statusCode)
handler, ok := app.errorHandler[statusCode]
if !ok {
defaultErrorHandler(ctx, data...)
return
}
handler(ctx)
} | go | func (app *Application) handleError(ctx *Context, statusCode int, data ...map[string]interface{}) {
ctx.SendStatus(statusCode)
handler, ok := app.errorHandler[statusCode]
if !ok {
defaultErrorHandler(ctx, data...)
return
}
handler(ctx)
} | [
"func",
"(",
"app",
"*",
"Application",
")",
"handleError",
"(",
"ctx",
"*",
"Context",
",",
"statusCode",
"int",
",",
"data",
"...",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"ctx",
".",
"SendStatus",
"(",
"statusCode",
")",
"\n",
... | // Handles a HTTP Error, if there is a corresponding handler set in the map
// `errorHandler`, then call it. Otherwise call the `defaultErrorHandler`. | [
"Handles",
"a",
"HTTP",
"Error",
"if",
"there",
"is",
"a",
"corresponding",
"handler",
"set",
"in",
"the",
"map",
"errorHandler",
"then",
"call",
"it",
".",
"Otherwise",
"call",
"the",
"defaultErrorHandler",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/app.go#L176-L184 |
5,406 | dinever/golf | middleware.go | NewChain | func NewChain(handlerArray ...MiddlewareHandlerFunc) *Chain {
c := new(Chain)
c.middlewareHandlers = handlerArray
return c
} | go | func NewChain(handlerArray ...MiddlewareHandlerFunc) *Chain {
c := new(Chain)
c.middlewareHandlers = handlerArray
return c
} | [
"func",
"NewChain",
"(",
"handlerArray",
"...",
"MiddlewareHandlerFunc",
")",
"*",
"Chain",
"{",
"c",
":=",
"new",
"(",
"Chain",
")",
"\n",
"c",
".",
"middlewareHandlers",
"=",
"handlerArray",
"\n",
"return",
"c",
"\n",
"}"
] | // NewChain Creates a new middleware chain. | [
"NewChain",
"Creates",
"a",
"new",
"middleware",
"chain",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/middleware.go#L20-L24 |
5,407 | dinever/golf | middleware.go | Final | func (c Chain) Final(fn HandlerFunc) HandlerFunc {
for i := len(c.middlewareHandlers) - 1; i >= 0; i-- {
fn = c.middlewareHandlers[i](fn)
}
return fn
} | go | func (c Chain) Final(fn HandlerFunc) HandlerFunc {
for i := len(c.middlewareHandlers) - 1; i >= 0; i-- {
fn = c.middlewareHandlers[i](fn)
}
return fn
} | [
"func",
"(",
"c",
"Chain",
")",
"Final",
"(",
"fn",
"HandlerFunc",
")",
"HandlerFunc",
"{",
"for",
"i",
":=",
"len",
"(",
"c",
".",
"middlewareHandlers",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"fn",
"=",
"c",
".",
"middlewareHan... | // Final indicates a final Handler, chain the multiple middlewares together with the
// handler, and return them together as a handler. | [
"Final",
"indicates",
"a",
"final",
"Handler",
"chain",
"the",
"multiple",
"middlewares",
"together",
"with",
"the",
"handler",
"and",
"return",
"them",
"together",
"as",
"a",
"handler",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/middleware.go#L28-L33 |
5,408 | dinever/golf | middleware.go | Append | func (c *Chain) Append(fn MiddlewareHandlerFunc) {
c.middlewareHandlers = append(c.middlewareHandlers, fn)
} | go | func (c *Chain) Append(fn MiddlewareHandlerFunc) {
c.middlewareHandlers = append(c.middlewareHandlers, fn)
} | [
"func",
"(",
"c",
"*",
"Chain",
")",
"Append",
"(",
"fn",
"MiddlewareHandlerFunc",
")",
"{",
"c",
".",
"middlewareHandlers",
"=",
"append",
"(",
"c",
".",
"middlewareHandlers",
",",
"fn",
")",
"\n",
"}"
] | // Append a middleware to the middleware chain | [
"Append",
"a",
"middleware",
"to",
"the",
"middleware",
"chain"
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/middleware.go#L36-L38 |
5,409 | dinever/golf | middleware.go | XSRFProtectionMiddleware | func XSRFProtectionMiddleware(next HandlerFunc) HandlerFunc {
fn := func(ctx *Context) {
if ctx.Request.Method == "POST" || ctx.Request.Method == "PUT" || ctx.Request.Method == "DELETE" {
if !ctx.checkXSRFToken() {
ctx.Abort(403)
return
}
}
next(ctx)
}
return fn
} | go | func XSRFProtectionMiddleware(next HandlerFunc) HandlerFunc {
fn := func(ctx *Context) {
if ctx.Request.Method == "POST" || ctx.Request.Method == "PUT" || ctx.Request.Method == "DELETE" {
if !ctx.checkXSRFToken() {
ctx.Abort(403)
return
}
}
next(ctx)
}
return fn
} | [
"func",
"XSRFProtectionMiddleware",
"(",
"next",
"HandlerFunc",
")",
"HandlerFunc",
"{",
"fn",
":=",
"func",
"(",
"ctx",
"*",
"Context",
")",
"{",
"if",
"ctx",
".",
"Request",
".",
"Method",
"==",
"\"",
"\"",
"||",
"ctx",
".",
"Request",
".",
"Method",
... | // XSRFProtectionMiddleware is the built-in middleware for XSRF protection. | [
"XSRFProtectionMiddleware",
"is",
"the",
"built",
"-",
"in",
"middleware",
"for",
"XSRF",
"protection",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/middleware.go#L118-L129 |
5,410 | dinever/golf | middleware.go | RecoverMiddleware | func RecoverMiddleware(next HandlerFunc) HandlerFunc {
fn := func(ctx *Context) {
defer func() {
if err := recover(); err != nil {
e := NewError(err)
httpRequest, _ := httputil.DumpRequest(ctx.Request, true)
log.Printf("[Recovery] panic recovered:\n%s\n%s\n%s", string(httpRequest), err, e.StackTraceSt... | go | func RecoverMiddleware(next HandlerFunc) HandlerFunc {
fn := func(ctx *Context) {
defer func() {
if err := recover(); err != nil {
e := NewError(err)
httpRequest, _ := httputil.DumpRequest(ctx.Request, true)
log.Printf("[Recovery] panic recovered:\n%s\n%s\n%s", string(httpRequest), err, e.StackTraceSt... | [
"func",
"RecoverMiddleware",
"(",
"next",
"HandlerFunc",
")",
"HandlerFunc",
"{",
"fn",
":=",
"func",
"(",
"ctx",
"*",
"Context",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
":=",
"recover",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"e",
"... | // RecoverMiddleware is the built-in middleware for recovering from errors. | [
"RecoverMiddleware",
"is",
"the",
"built",
"-",
"in",
"middleware",
"for",
"recovering",
"from",
"errors",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/middleware.go#L132-L152 |
5,411 | dinever/golf | middleware.go | SessionMiddleware | func SessionMiddleware(next HandlerFunc) HandlerFunc {
fn := func(ctx *Context) {
if ctx.App.SessionManager != nil {
ctx.retrieveSession()
}
next(ctx)
}
return fn
} | go | func SessionMiddleware(next HandlerFunc) HandlerFunc {
fn := func(ctx *Context) {
if ctx.App.SessionManager != nil {
ctx.retrieveSession()
}
next(ctx)
}
return fn
} | [
"func",
"SessionMiddleware",
"(",
"next",
"HandlerFunc",
")",
"HandlerFunc",
"{",
"fn",
":=",
"func",
"(",
"ctx",
"*",
"Context",
")",
"{",
"if",
"ctx",
".",
"App",
".",
"SessionManager",
"!=",
"nil",
"{",
"ctx",
".",
"retrieveSession",
"(",
")",
"\n",
... | // SessionMiddleware handles session of the request | [
"SessionMiddleware",
"handles",
"session",
"of",
"the",
"request"
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/middleware.go#L155-L163 |
5,412 | dinever/golf | router.go | ByName | func (p *Parameter) ByName(name string) (string, error) {
if i, has := p.names[name]; has {
return p.findParam(i)
}
return "", fmt.Errorf("Parameter not found")
} | go | func (p *Parameter) ByName(name string) (string, error) {
if i, has := p.names[name]; has {
return p.findParam(i)
}
return "", fmt.Errorf("Parameter not found")
} | [
"func",
"(",
"p",
"*",
"Parameter",
")",
"ByName",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"i",
",",
"has",
":=",
"p",
".",
"names",
"[",
"name",
"]",
";",
"has",
"{",
"return",
"p",
".",
"findParam",
"(",
"i",
... | //ByName returns the url parameter by name | [
"ByName",
"returns",
"the",
"url",
"parameter",
"by",
"name"
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/router.go#L116-L121 |
5,413 | dinever/golf | router.go | findParam | func (p *Parameter) findParam(idx int) (string, error) {
index := len(p.names) - 1
urlPath := p.path
pathLen := len(p.path)
node := p.node
for node != nil {
if node.text[0] == ':' {
ctn := lastIndexByte(urlPath, '/')
if ctn == -1 {
return "", fmt.Errorf("Parameter not found")
}
pathLen = ctn + 1... | go | func (p *Parameter) findParam(idx int) (string, error) {
index := len(p.names) - 1
urlPath := p.path
pathLen := len(p.path)
node := p.node
for node != nil {
if node.text[0] == ':' {
ctn := lastIndexByte(urlPath, '/')
if ctn == -1 {
return "", fmt.Errorf("Parameter not found")
}
pathLen = ctn + 1... | [
"func",
"(",
"p",
"*",
"Parameter",
")",
"findParam",
"(",
"idx",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"index",
":=",
"len",
"(",
"p",
".",
"names",
")",
"-",
"1",
"\n",
"urlPath",
":=",
"p",
".",
"path",
"\n",
"pathLen",
":=",
"l... | //findParam walks up the matched node looking for parameters returns the last parameter | [
"findParam",
"walks",
"up",
"the",
"matched",
"node",
"looking",
"for",
"parameters",
"returns",
"the",
"last",
"parameter"
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/router.go#L133-L157 |
5,414 | dinever/golf | error.go | defaultErrorHandler | func defaultErrorHandler(ctx *Context, data ...map[string]interface{}) {
var renderData map[string]interface{}
if len(data) == 0 {
renderData = make(map[string]interface{})
renderData["Code"] = ctx.statusCode
renderData["Title"] = http.StatusText(ctx.statusCode)
renderData["Message"] = http.StatusText(ctx.sta... | go | func defaultErrorHandler(ctx *Context, data ...map[string]interface{}) {
var renderData map[string]interface{}
if len(data) == 0 {
renderData = make(map[string]interface{})
renderData["Code"] = ctx.statusCode
renderData["Title"] = http.StatusText(ctx.statusCode)
renderData["Message"] = http.StatusText(ctx.sta... | [
"func",
"defaultErrorHandler",
"(",
"ctx",
"*",
"Context",
",",
"data",
"...",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"{",
"var",
"renderData",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"if",
"len",
"(",
"data",
")",
"==... | // The default error handler | [
"The",
"default",
"error",
"handler"
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/error.go#L104-L129 |
5,415 | dinever/golf | error.go | StackTraceString | func (e Error) StackTraceString() string {
buf := new(bytes.Buffer)
for _, v := range e.Stack {
fmt.Fprintf(buf, "%s: %s\n\t%s\n", v.File, v.Number, v.Method)
}
return string(buf.Bytes())
} | go | func (e Error) StackTraceString() string {
buf := new(bytes.Buffer)
for _, v := range e.Stack {
fmt.Fprintf(buf, "%s: %s\n\t%s\n", v.File, v.Number, v.Method)
}
return string(buf.Bytes())
} | [
"func",
"(",
"e",
"Error",
")",
"StackTraceString",
"(",
")",
"string",
"{",
"buf",
":=",
"new",
"(",
"bytes",
".",
"Buffer",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"e",
".",
"Stack",
"{",
"fmt",
".",
"Fprintf",
"(",
"buf",
",",
"\"",
... | // StackTraceString returns the stack trace in a string format. | [
"StackTraceString",
"returns",
"the",
"stack",
"trace",
"in",
"a",
"string",
"format",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/error.go#L152-L158 |
5,416 | dinever/golf | error.go | NewError | func NewError(msg interface{}) Error {
var err error
switch t := msg.(type) {
case Error:
return t
case error:
err = t
default:
err = fmt.Errorf("%v", t)
}
return Error{
err: err,
Message: err.Error(),
Class: reflect.TypeOf(err).String(),
Stack: generateStack(3),
}
} | go | func NewError(msg interface{}) Error {
var err error
switch t := msg.(type) {
case Error:
return t
case error:
err = t
default:
err = fmt.Errorf("%v", t)
}
return Error{
err: err,
Message: err.Error(),
Class: reflect.TypeOf(err).String(),
Stack: generateStack(3),
}
} | [
"func",
"NewError",
"(",
"msg",
"interface",
"{",
"}",
")",
"Error",
"{",
"var",
"err",
"error",
"\n\n",
"switch",
"t",
":=",
"msg",
".",
"(",
"type",
")",
"{",
"case",
"Error",
":",
"return",
"t",
"\n",
"case",
"error",
":",
"err",
"=",
"t",
"\n... | // NewError creates a new error instance | [
"NewError",
"creates",
"a",
"new",
"error",
"instance"
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/error.go#L166-L184 |
5,417 | dinever/golf | session.go | NewMemorySessionManager | func NewMemorySessionManager() *MemorySessionManager {
mgr := new(MemorySessionManager)
mgr.sessions = make(map[string]*MemorySession)
mgr.GarbageCollection()
return mgr
} | go | func NewMemorySessionManager() *MemorySessionManager {
mgr := new(MemorySessionManager)
mgr.sessions = make(map[string]*MemorySession)
mgr.GarbageCollection()
return mgr
} | [
"func",
"NewMemorySessionManager",
"(",
")",
"*",
"MemorySessionManager",
"{",
"mgr",
":=",
"new",
"(",
"MemorySessionManager",
")",
"\n",
"mgr",
".",
"sessions",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"MemorySession",
")",
"\n",
"mgr",
".",
"Ga... | // NewMemorySessionManager creates a new session manager. | [
"NewMemorySessionManager",
"creates",
"a",
"new",
"session",
"manager",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/session.go#L31-L36 |
5,418 | dinever/golf | session.go | Session | func (mgr *MemorySessionManager) Session(sid string) (Session, error) {
mgr.lock.RLock()
if s, ok := mgr.sessions[sid]; ok {
s.createdAt = time.Now()
mgr.lock.RUnlock()
return s, nil
}
mgr.lock.RUnlock()
return nil, fmt.Errorf("Can not retrieve session with id %s", sid)
} | go | func (mgr *MemorySessionManager) Session(sid string) (Session, error) {
mgr.lock.RLock()
if s, ok := mgr.sessions[sid]; ok {
s.createdAt = time.Now()
mgr.lock.RUnlock()
return s, nil
}
mgr.lock.RUnlock()
return nil, fmt.Errorf("Can not retrieve session with id %s", sid)
} | [
"func",
"(",
"mgr",
"*",
"MemorySessionManager",
")",
"Session",
"(",
"sid",
"string",
")",
"(",
"Session",
",",
"error",
")",
"{",
"mgr",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"if",
"s",
",",
"ok",
":=",
"mgr",
".",
"sessions",
"[",
"sid",
... | // Session gets the session instance by indicating a session id. | [
"Session",
"gets",
"the",
"session",
"instance",
"by",
"indicating",
"a",
"session",
"id",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/session.go#L48-L57 |
5,419 | dinever/golf | session.go | NewSession | func (mgr *MemorySessionManager) NewSession() (Session, error) {
sid, err := mgr.sessionID()
if err != nil {
return nil, err
}
s := MemorySession{sid: sid, data: make(map[string]interface{}), createdAt: time.Now()}
mgr.lock.Lock()
mgr.sessions[sid] = &s
mgr.lock.Unlock()
return &s, nil
} | go | func (mgr *MemorySessionManager) NewSession() (Session, error) {
sid, err := mgr.sessionID()
if err != nil {
return nil, err
}
s := MemorySession{sid: sid, data: make(map[string]interface{}), createdAt: time.Now()}
mgr.lock.Lock()
mgr.sessions[sid] = &s
mgr.lock.Unlock()
return &s, nil
} | [
"func",
"(",
"mgr",
"*",
"MemorySessionManager",
")",
"NewSession",
"(",
")",
"(",
"Session",
",",
"error",
")",
"{",
"sid",
",",
"err",
":=",
"mgr",
".",
"sessionID",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n"... | // NewSession creates and returns a new session. | [
"NewSession",
"creates",
"and",
"returns",
"a",
"new",
"session",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/session.go#L60-L70 |
5,420 | dinever/golf | session.go | GarbageCollection | func (mgr *MemorySessionManager) GarbageCollection() {
for k, v := range mgr.sessions {
if v.isExpired() {
delete(mgr.sessions, k)
}
}
time.AfterFunc(time.Duration(gcTimeInterval)*time.Second, mgr.GarbageCollection)
} | go | func (mgr *MemorySessionManager) GarbageCollection() {
for k, v := range mgr.sessions {
if v.isExpired() {
delete(mgr.sessions, k)
}
}
time.AfterFunc(time.Duration(gcTimeInterval)*time.Second, mgr.GarbageCollection)
} | [
"func",
"(",
"mgr",
"*",
"MemorySessionManager",
")",
"GarbageCollection",
"(",
")",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"mgr",
".",
"sessions",
"{",
"if",
"v",
".",
"isExpired",
"(",
")",
"{",
"delete",
"(",
"mgr",
".",
"sessions",
",",
"k",
... | // GarbageCollection recycles expired sessions, delete them from the session manager. | [
"GarbageCollection",
"recycles",
"expired",
"sessions",
"delete",
"them",
"from",
"the",
"session",
"manager",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/session.go#L73-L80 |
5,421 | dinever/golf | session.go | Set | func (s *MemorySession) Set(key string, value interface{}) error {
s.data[key] = value
return nil
} | go | func (s *MemorySession) Set(key string, value interface{}) error {
s.data[key] = value
return nil
} | [
"func",
"(",
"s",
"*",
"MemorySession",
")",
"Set",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"s",
".",
"data",
"[",
"key",
"]",
"=",
"value",
"\n",
"return",
"nil",
"\n",
"}"
] | // Set method sets the key value pair in the session. | [
"Set",
"method",
"sets",
"the",
"key",
"value",
"pair",
"in",
"the",
"session",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/session.go#L109-L112 |
5,422 | dinever/golf | session.go | Get | func (s *MemorySession) Get(key string) (interface{}, error) {
if value, ok := s.data[key]; ok {
return value, nil
}
return nil, fmt.Errorf("key %q in session (id %s) not found", key, s.sid)
} | go | func (s *MemorySession) Get(key string) (interface{}, error) {
if value, ok := s.data[key]; ok {
return value, nil
}
return nil, fmt.Errorf("key %q in session (id %s) not found", key, s.sid)
} | [
"func",
"(",
"s",
"*",
"MemorySession",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"value",
",",
"ok",
":=",
"s",
".",
"data",
"[",
"key",
"]",
";",
"ok",
"{",
"return",
"value",
",",
"nil",... | // Get method gets the value by given a key in the session. | [
"Get",
"method",
"gets",
"the",
"value",
"by",
"given",
"a",
"key",
"in",
"the",
"session",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/session.go#L115-L120 |
5,423 | dinever/golf | session.go | Delete | func (s *MemorySession) Delete(key string) error {
delete(s.data, key)
return nil
} | go | func (s *MemorySession) Delete(key string) error {
delete(s.data, key)
return nil
} | [
"func",
"(",
"s",
"*",
"MemorySession",
")",
"Delete",
"(",
"key",
"string",
")",
"error",
"{",
"delete",
"(",
"s",
".",
"data",
",",
"key",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Delete method deletes the value by given a key in the session. | [
"Delete",
"method",
"deletes",
"the",
"value",
"by",
"given",
"a",
"key",
"in",
"the",
"session",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/session.go#L123-L126 |
5,424 | dinever/golf | template.go | LoadTemplate | func (loader *FileSystemLoader) LoadTemplate(name string) (string, error) {
f, err := os.Open(path.Join(loader.BaseDir, name))
if err != nil {
return "", err
}
b, err := ioutil.ReadAll(f)
return string(b), err
} | go | func (loader *FileSystemLoader) LoadTemplate(name string) (string, error) {
f, err := os.Open(path.Join(loader.BaseDir, name))
if err != nil {
return "", err
}
b, err := ioutil.ReadAll(f)
return string(b), err
} | [
"func",
"(",
"loader",
"*",
"FileSystemLoader",
")",
"LoadTemplate",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
".",
"Join",
"(",
"loader",
".",
"BaseDir",
",",
"name",
... | // LoadTemplate loads a template from a file. | [
"LoadTemplate",
"loads",
"a",
"template",
"from",
"a",
"file",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/template.go#L31-L38 |
5,425 | dinever/golf | template.go | LoadTemplate | func (loader *MapLoader) LoadTemplate(name string) (string, error) {
if src, ok := (*loader)[name]; ok {
return src, nil
}
return "", Errorf("Could not find template " + name)
} | go | func (loader *MapLoader) LoadTemplate(name string) (string, error) {
if src, ok := (*loader)[name]; ok {
return src, nil
}
return "", Errorf("Could not find template " + name)
} | [
"func",
"(",
"loader",
"*",
"MapLoader",
")",
"LoadTemplate",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"src",
",",
"ok",
":=",
"(",
"*",
"loader",
")",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"src",
",",
"nil",... | // LoadTemplate loads a template from the map. | [
"LoadTemplate",
"loads",
"a",
"template",
"from",
"the",
"map",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/template.go#L45-L50 |
5,426 | dinever/golf | template.go | Render | func (t *TemplateManager) Render(w io.Writer, name string, data interface{}) error {
stack := []*Template{}
tplSrc, err := t.getSrc(name)
if err != nil {
return err
}
err = t.push(&stack, tplSrc, name)
if err != nil {
return err
}
tpl, err := t.assemble(stack)
if err != nil {
return err
}
if err != nil... | go | func (t *TemplateManager) Render(w io.Writer, name string, data interface{}) error {
stack := []*Template{}
tplSrc, err := t.getSrc(name)
if err != nil {
return err
}
err = t.push(&stack, tplSrc, name)
if err != nil {
return err
}
tpl, err := t.assemble(stack)
if err != nil {
return err
}
if err != nil... | [
"func",
"(",
"t",
"*",
"TemplateManager",
")",
"Render",
"(",
"w",
"io",
".",
"Writer",
",",
"name",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"error",
"{",
"stack",
":=",
"[",
"]",
"*",
"Template",
"{",
"}",
"\n",
"tplSrc",
",",
"err",
... | // Render renders a template and writes it to the io.Writer interface. | [
"Render",
"renders",
"a",
"template",
"and",
"writes",
"it",
"to",
"the",
"io",
".",
"Writer",
"interface",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/template.go#L65-L93 |
5,427 | dinever/golf | template.go | RenderFromString | func (t *TemplateManager) RenderFromString(w io.Writer, tplSrc string, data interface{}) error {
stack := []*Template{}
t.push(&stack, tplSrc, "_fromString")
tpl, err := t.assemble(stack)
if err != nil {
return err
}
err = tpl.Execute(w, data)
if err != nil {
return err
}
return nil
} | go | func (t *TemplateManager) RenderFromString(w io.Writer, tplSrc string, data interface{}) error {
stack := []*Template{}
t.push(&stack, tplSrc, "_fromString")
tpl, err := t.assemble(stack)
if err != nil {
return err
}
err = tpl.Execute(w, data)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"t",
"*",
"TemplateManager",
")",
"RenderFromString",
"(",
"w",
"io",
".",
"Writer",
",",
"tplSrc",
"string",
",",
"data",
"interface",
"{",
"}",
")",
"error",
"{",
"stack",
":=",
"[",
"]",
"*",
"Template",
"{",
"}",
"\n",
"t",
".",
"p... | // RenderFromString renders a template from string. | [
"RenderFromString",
"renders",
"a",
"template",
"from",
"string",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/template.go#L96-L110 |
5,428 | dinever/golf | view.go | NewView | func NewView() *View {
view := new(View)
view.templateLoader = make(map[string]*TemplateManager)
view.FuncMap = make(template.FuncMap)
view.FuncMap["Html"] = func(s string) template.HTML { return template.HTML(s) }
return view
} | go | func NewView() *View {
view := new(View)
view.templateLoader = make(map[string]*TemplateManager)
view.FuncMap = make(template.FuncMap)
view.FuncMap["Html"] = func(s string) template.HTML { return template.HTML(s) }
return view
} | [
"func",
"NewView",
"(",
")",
"*",
"View",
"{",
"view",
":=",
"new",
"(",
"View",
")",
"\n",
"view",
".",
"templateLoader",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"TemplateManager",
")",
"\n",
"view",
".",
"FuncMap",
"=",
"make",
"(",
"te... | // NewView creates a new View instance. | [
"NewView",
"creates",
"a",
"new",
"View",
"instance",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/view.go#L19-L25 |
5,429 | dinever/golf | view.go | Render | func (view *View) Render(loaderName string, filePath string, data map[string]interface{}) (string, error) {
loader, ok := view.templateLoader[loaderName]
if !ok {
panic(errors.New("Template loader not found: " + loaderName))
}
var buf bytes.Buffer
err := loader.Render(&buf, filePath, data)
if err != nil {
ret... | go | func (view *View) Render(loaderName string, filePath string, data map[string]interface{}) (string, error) {
loader, ok := view.templateLoader[loaderName]
if !ok {
panic(errors.New("Template loader not found: " + loaderName))
}
var buf bytes.Buffer
err := loader.Render(&buf, filePath, data)
if err != nil {
ret... | [
"func",
"(",
"view",
"*",
"View",
")",
"Render",
"(",
"loaderName",
"string",
",",
"filePath",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"loader",
",",
"ok",
":=",
"view",
"... | // Render renders a template by indicating the file path and the name of the template loader. | [
"Render",
"renders",
"a",
"template",
"by",
"indicating",
"the",
"file",
"path",
"and",
"the",
"name",
"of",
"the",
"template",
"loader",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/view.go#L28-L39 |
5,430 | dinever/golf | view.go | RenderFromString | func (view *View) RenderFromString(loaderName string, tplSrc string, data map[string]interface{}) (string, error) {
var buf bytes.Buffer
// If loaderName is not indicated, use the default template library of Go, no syntax like
// `extends` or `include` will be supported.
if loaderName == "" {
tmpl := template.New... | go | func (view *View) RenderFromString(loaderName string, tplSrc string, data map[string]interface{}) (string, error) {
var buf bytes.Buffer
// If loaderName is not indicated, use the default template library of Go, no syntax like
// `extends` or `include` will be supported.
if loaderName == "" {
tmpl := template.New... | [
"func",
"(",
"view",
"*",
"View",
")",
"RenderFromString",
"(",
"loaderName",
"string",
",",
"tplSrc",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"buf",
"bytes",
".",
"B... | // RenderFromString does the same thing as render but renders a template by
// indicating the template source from tplSrc. | [
"RenderFromString",
"does",
"the",
"same",
"thing",
"as",
"render",
"but",
"renders",
"a",
"template",
"by",
"indicating",
"the",
"template",
"source",
"from",
"tplSrc",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/view.go#L43-L62 |
5,431 | dinever/golf | view.go | SetTemplateLoader | func (view *View) SetTemplateLoader(name string, path string) {
loader := &TemplateManager{
Loader: &FileSystemLoader{
BaseDir: path,
},
FuncMap: view.FuncMap,
}
view.templateLoader[name] = loader
} | go | func (view *View) SetTemplateLoader(name string, path string) {
loader := &TemplateManager{
Loader: &FileSystemLoader{
BaseDir: path,
},
FuncMap: view.FuncMap,
}
view.templateLoader[name] = loader
} | [
"func",
"(",
"view",
"*",
"View",
")",
"SetTemplateLoader",
"(",
"name",
"string",
",",
"path",
"string",
")",
"{",
"loader",
":=",
"&",
"TemplateManager",
"{",
"Loader",
":",
"&",
"FileSystemLoader",
"{",
"BaseDir",
":",
"path",
",",
"}",
",",
"FuncMap"... | // SetTemplateLoader sets the template loader by indicating the name and the path. | [
"SetTemplateLoader",
"sets",
"the",
"template",
"loader",
"by",
"indicating",
"the",
"name",
"and",
"the",
"path",
"."
] | 11abebbbb289ef6f35e518db394eaca39cee8732 | https://github.com/dinever/golf/blob/11abebbbb289ef6f35e518db394eaca39cee8732/view.go#L65-L73 |
5,432 | gorgonia/cu | cmd/genlib/signature.go | flagType | func flagType(name string) string {
switch name {
case "cuCtxCreate", "cuDevicePrimaryCtxSetFlags":
return "ContextFlags"
case "cuLinkCreate":
panic("Unhandled")
case "cuStreamCreate", "cuStreamCreateWithPriority":
return "StreamFlags"
case "cuEventCreate":
return "EventFlags"
case "cuTexRefSetFlags":
r... | go | func flagType(name string) string {
switch name {
case "cuCtxCreate", "cuDevicePrimaryCtxSetFlags":
return "ContextFlags"
case "cuLinkCreate":
panic("Unhandled")
case "cuStreamCreate", "cuStreamCreateWithPriority":
return "StreamFlags"
case "cuEventCreate":
return "EventFlags"
case "cuTexRefSetFlags":
r... | [
"func",
"flagType",
"(",
"name",
"string",
")",
"string",
"{",
"switch",
"name",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
":",
"return",
"\"",
"\"",
"\n",
"case",
"\"",
"\"",
":",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"case",
"\"",
"\"",
",",
"... | // flag type returns the correct flag type for the Go signatures | [
"flag",
"type",
"returns",
"the",
"correct",
"flag",
"type",
"for",
"the",
"Go",
"signatures"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/cmd/genlib/signature.go#L207-L223 |
5,433 | gorgonia/cu | stream.go | MakeStream | func MakeStream(flags StreamFlags) (Stream, error) {
var s Stream
err := result(C.cuStreamCreate(&s.s, C.uint(flags)))
return s, err
} | go | func MakeStream(flags StreamFlags) (Stream, error) {
var s Stream
err := result(C.cuStreamCreate(&s.s, C.uint(flags)))
return s, err
} | [
"func",
"MakeStream",
"(",
"flags",
"StreamFlags",
")",
"(",
"Stream",
",",
"error",
")",
"{",
"var",
"s",
"Stream",
"\n",
"err",
":=",
"result",
"(",
"C",
".",
"cuStreamCreate",
"(",
"&",
"s",
".",
"s",
",",
"C",
".",
"uint",
"(",
"flags",
")",
... | // MakeStream creates a stream. The flags determines the behaviors of the stream. | [
"MakeStream",
"creates",
"a",
"stream",
".",
"The",
"flags",
"determines",
"the",
"behaviors",
"of",
"the",
"stream",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/stream.go#L23-L27 |
5,434 | gorgonia/cu | stream.go | MakeStreamWithPriority | func MakeStreamWithPriority(priority int, flags StreamFlags) (Stream, error) {
var s Stream
err := result(C.cuStreamCreateWithPriority(&s.s, C.uint(flags), C.int(priority)))
return s, err
} | go | func MakeStreamWithPriority(priority int, flags StreamFlags) (Stream, error) {
var s Stream
err := result(C.cuStreamCreateWithPriority(&s.s, C.uint(flags), C.int(priority)))
return s, err
} | [
"func",
"MakeStreamWithPriority",
"(",
"priority",
"int",
",",
"flags",
"StreamFlags",
")",
"(",
"Stream",
",",
"error",
")",
"{",
"var",
"s",
"Stream",
"\n",
"err",
":=",
"result",
"(",
"C",
".",
"cuStreamCreateWithPriority",
"(",
"&",
"s",
".",
"s",
",... | // MakeStreamWithPriority creates a stream with the given priority. The flags determines the behaviors of the stream.
// This API alters the scheduler priority of work in the stream. Work in a higher priority stream may preempt work already executing in a low priority stream.
//
// `priority` follows a convention where... | [
"MakeStreamWithPriority",
"creates",
"a",
"stream",
"with",
"the",
"given",
"priority",
".",
"The",
"flags",
"determines",
"the",
"behaviors",
"of",
"the",
"stream",
".",
"This",
"API",
"alters",
"the",
"scheduler",
"priority",
"of",
"work",
"in",
"the",
"stre... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/stream.go#L37-L41 |
5,435 | gorgonia/cu | cmd/gencudnn/generatethis.go | generateCRUD | func generateCRUD(buf io.Writer, t *cc.TranslationUnit, fnType string) {
decls, err := bindgen.Get(t, functions)
handleErr(err)
var a = make(map[string][]string)
switch fnType {
case "create":
fmt.Fprintf(buf, "creations = ")
case "get":
fmt.Fprintf(buf, "getFns = ")
case "set":
fmt.Fprintf(buf, "setFns =... | go | func generateCRUD(buf io.Writer, t *cc.TranslationUnit, fnType string) {
decls, err := bindgen.Get(t, functions)
handleErr(err)
var a = make(map[string][]string)
switch fnType {
case "create":
fmt.Fprintf(buf, "creations = ")
case "get":
fmt.Fprintf(buf, "getFns = ")
case "set":
fmt.Fprintf(buf, "setFns =... | [
"func",
"generateCRUD",
"(",
"buf",
"io",
".",
"Writer",
",",
"t",
"*",
"cc",
".",
"TranslationUnit",
",",
"fnType",
"string",
")",
"{",
"decls",
",",
"err",
":=",
"bindgen",
".",
"Get",
"(",
"t",
",",
"functions",
")",
"\n",
"handleErr",
"(",
"err",... | // generateCRUD creates lists of CRUD functions for the generateStubs function to consume | [
"generateCRUD",
"creates",
"lists",
"of",
"CRUD",
"functions",
"for",
"the",
"generateStubs",
"function",
"to",
"consume"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/cmd/gencudnn/generatethis.go#L56-L139 |
5,436 | gorgonia/cu | ctx.go | Close | func (ctx *Ctx) Close() error {
var empty C.CUcontext
if ctx.CUContext.ctx == empty {
return nil
}
if ctx.errChan != nil {
close(ctx.errChan)
ctx.errChan = nil
}
if ctx.work != nil {
close(ctx.work)
ctx.work = nil
}
err := result(C.cuCtxDestroy(C.CUcontext(unsafe.Pointer(ctx.CUContext.ctx))))
ctx.... | go | func (ctx *Ctx) Close() error {
var empty C.CUcontext
if ctx.CUContext.ctx == empty {
return nil
}
if ctx.errChan != nil {
close(ctx.errChan)
ctx.errChan = nil
}
if ctx.work != nil {
close(ctx.work)
ctx.work = nil
}
err := result(C.cuCtxDestroy(C.CUcontext(unsafe.Pointer(ctx.CUContext.ctx))))
ctx.... | [
"func",
"(",
"ctx",
"*",
"Ctx",
")",
"Close",
"(",
")",
"error",
"{",
"var",
"empty",
"C",
".",
"CUcontext",
"\n",
"if",
"ctx",
".",
"CUContext",
".",
"ctx",
"==",
"empty",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"ctx",
".",
"errChan",
"!=... | // Close destroys the CUDA context and associated resources that has been created. Additionally, all channels of communications will be closed. | [
"Close",
"destroys",
"the",
"CUDA",
"context",
"and",
"associated",
"resources",
"that",
"has",
"been",
"created",
".",
"Additionally",
"all",
"channels",
"of",
"communications",
"will",
"be",
"closed",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/ctx.go#L84-L103 |
5,437 | gorgonia/cu | dnn/pooling.go | NewPooling | func NewPooling(mode PoolingMode, maxpoolingNanOpt NanPropagation, shape, strides, padding []int) (retVal *Pooling, err error) {
var internal C.cudnnPoolingDescriptor_t
if err = result(C.cudnnCreatePoolingDescriptor(&internal)); err != nil {
return nil, err
}
// checks shapes and strides
if len(shape) != len(st... | go | func NewPooling(mode PoolingMode, maxpoolingNanOpt NanPropagation, shape, strides, padding []int) (retVal *Pooling, err error) {
var internal C.cudnnPoolingDescriptor_t
if err = result(C.cudnnCreatePoolingDescriptor(&internal)); err != nil {
return nil, err
}
// checks shapes and strides
if len(shape) != len(st... | [
"func",
"NewPooling",
"(",
"mode",
"PoolingMode",
",",
"maxpoolingNanOpt",
"NanPropagation",
",",
"shape",
",",
"strides",
",",
"padding",
"[",
"]",
"int",
")",
"(",
"retVal",
"*",
"Pooling",
",",
"err",
"error",
")",
"{",
"var",
"internal",
"C",
".",
"c... | // NewPooling creates a new Pooling op. | [
"NewPooling",
"creates",
"a",
"new",
"Pooling",
"op",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/pooling.go#L31-L75 |
5,438 | gorgonia/cu | dnn/pooling.go | OutputShape | func (p *Pooling) OutputShape(input *TensorDescriptor, dims int) (retVal []int, err error) {
if dims == p.outDims && shapeEq(input.shape, p.inputTensor) {
return cloneShape(p.outputShape), nil
}
return p.CalcOutputShape(input, dims)
} | go | func (p *Pooling) OutputShape(input *TensorDescriptor, dims int) (retVal []int, err error) {
if dims == p.outDims && shapeEq(input.shape, p.inputTensor) {
return cloneShape(p.outputShape), nil
}
return p.CalcOutputShape(input, dims)
} | [
"func",
"(",
"p",
"*",
"Pooling",
")",
"OutputShape",
"(",
"input",
"*",
"TensorDescriptor",
",",
"dims",
"int",
")",
"(",
"retVal",
"[",
"]",
"int",
",",
"err",
"error",
")",
"{",
"if",
"dims",
"==",
"p",
".",
"outDims",
"&&",
"shapeEq",
"(",
"inp... | // OutputShape computes the output shape given the input tensor.
//
// This method caches the outputShape. If a inputTensor is seen before, and the dims is exactly the same, then the cached output shape is used | [
"OutputShape",
"computes",
"the",
"output",
"shape",
"given",
"the",
"input",
"tensor",
".",
"This",
"method",
"caches",
"the",
"outputShape",
".",
"If",
"a",
"inputTensor",
"is",
"seen",
"before",
"and",
"the",
"dims",
"is",
"exactly",
"the",
"same",
"then"... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/pooling.go#L95-L100 |
5,439 | gorgonia/cu | dnn/pooling.go | CalcOutputShape | func (p *Pooling) CalcOutputShape(input *TensorDescriptor, dims int) (retVal []int, err error) {
p.outDims = dims
p.inputTensor = cloneShape(input.shape)
switch dims {
case 0:
return nil, errors.Errorf("Cannot work on dims of 0")
case 2:
p.outputShape = make([]int, 4)
n := (*C.int)(unsafe.Pointer(&p.outputS... | go | func (p *Pooling) CalcOutputShape(input *TensorDescriptor, dims int) (retVal []int, err error) {
p.outDims = dims
p.inputTensor = cloneShape(input.shape)
switch dims {
case 0:
return nil, errors.Errorf("Cannot work on dims of 0")
case 2:
p.outputShape = make([]int, 4)
n := (*C.int)(unsafe.Pointer(&p.outputS... | [
"func",
"(",
"p",
"*",
"Pooling",
")",
"CalcOutputShape",
"(",
"input",
"*",
"TensorDescriptor",
",",
"dims",
"int",
")",
"(",
"retVal",
"[",
"]",
"int",
",",
"err",
"error",
")",
"{",
"p",
".",
"outDims",
"=",
"dims",
"\n",
"p",
".",
"inputTensor",
... | // CalcOutputShape is like OutputShape, but doesn't go through a check for the cached value. | [
"CalcOutputShape",
"is",
"like",
"OutputShape",
"but",
"doesn",
"t",
"go",
"through",
"a",
"check",
"for",
"the",
"cached",
"value",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/pooling.go#L103-L129 |
5,440 | gorgonia/cu | dnn/generated_activation.go | NewActivation | func NewActivation(mode ActivationMode, reluNanOpt NanPropagation, coef float64) (retVal *Activation, err error) {
var internal C.cudnnActivationDescriptor_t
if err := result(C.cudnnCreateActivationDescriptor(&internal)); err != nil {
return nil, err
}
if err := result(C.cudnnSetActivationDescriptor(internal, mo... | go | func NewActivation(mode ActivationMode, reluNanOpt NanPropagation, coef float64) (retVal *Activation, err error) {
var internal C.cudnnActivationDescriptor_t
if err := result(C.cudnnCreateActivationDescriptor(&internal)); err != nil {
return nil, err
}
if err := result(C.cudnnSetActivationDescriptor(internal, mo... | [
"func",
"NewActivation",
"(",
"mode",
"ActivationMode",
",",
"reluNanOpt",
"NanPropagation",
",",
"coef",
"float64",
")",
"(",
"retVal",
"*",
"Activation",
",",
"err",
"error",
")",
"{",
"var",
"internal",
"C",
".",
"cudnnActivationDescriptor_t",
"\n",
"if",
"... | // NewActivation creates a new Activation. | [
"NewActivation",
"creates",
"a",
"new",
"Activation",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_activation.go#L19-L37 |
5,441 | gorgonia/cu | cucontext.go | Unlock | func (ctx CUContext) Unlock() error {
if err := Synchronize(); err != nil {
return err
}
runtime.UnlockOSThread()
return nil
} | go | func (ctx CUContext) Unlock() error {
if err := Synchronize(); err != nil {
return err
}
runtime.UnlockOSThread()
return nil
} | [
"func",
"(",
"ctx",
"CUContext",
")",
"Unlock",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"Synchronize",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"runtime",
".",
"UnlockOSThread",
"(",
")",
"\n",
"return",
"nil",
"... | // Unlock unlocks unbinds the goroutine from the OS thread | [
"Unlock",
"unlocks",
"unbinds",
"the",
"goroutine",
"from",
"the",
"OS",
"thread"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/cucontext.go#L57-L63 |
5,442 | gorgonia/cu | dnn/generated_reduction.go | NewReduction | func NewReduction(reduceTensorOp ReduceTensorOp, reduceTensorCompType DataType, reduceTensorNanOpt NanPropagation, reduceTensorIndices ReduceTensorIndices, reduceTensorIndicesType IndicesType) (retVal *Reduction, err error) {
var internal C.cudnnReduceTensorDescriptor_t
if err := result(C.cudnnCreateReduceTensorDescr... | go | func NewReduction(reduceTensorOp ReduceTensorOp, reduceTensorCompType DataType, reduceTensorNanOpt NanPropagation, reduceTensorIndices ReduceTensorIndices, reduceTensorIndicesType IndicesType) (retVal *Reduction, err error) {
var internal C.cudnnReduceTensorDescriptor_t
if err := result(C.cudnnCreateReduceTensorDescr... | [
"func",
"NewReduction",
"(",
"reduceTensorOp",
"ReduceTensorOp",
",",
"reduceTensorCompType",
"DataType",
",",
"reduceTensorNanOpt",
"NanPropagation",
",",
"reduceTensorIndices",
"ReduceTensorIndices",
",",
"reduceTensorIndicesType",
"IndicesType",
")",
"(",
"retVal",
"*",
... | // NewReduction creates a new Reduction. | [
"NewReduction",
"creates",
"a",
"new",
"Reduction",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_reduction.go#L21-L41 |
5,443 | gorgonia/cu | cmd/gencudnn/conversion.go | FirstTensor | func (s GoSignature) FirstTensor() string {
for _, p := range s.Params {
if strings.Contains(p.Type, ctypes2GoTypes["cudnnTensorDescriptor_t"]) {
return p.Name
}
}
panic(fmt.Sprintf("No tensors to check in %v", s))
} | go | func (s GoSignature) FirstTensor() string {
for _, p := range s.Params {
if strings.Contains(p.Type, ctypes2GoTypes["cudnnTensorDescriptor_t"]) {
return p.Name
}
}
panic(fmt.Sprintf("No tensors to check in %v", s))
} | [
"func",
"(",
"s",
"GoSignature",
")",
"FirstTensor",
"(",
")",
"string",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"s",
".",
"Params",
"{",
"if",
"strings",
".",
"Contains",
"(",
"p",
".",
"Type",
",",
"ctypes2GoTypes",
"[",
"\"",
"\"",
"]",
")",
... | // FirstTensor finds the first tensor parameter of the function and returns the name | [
"FirstTensor",
"finds",
"the",
"first",
"tensor",
"parameter",
"of",
"the",
"function",
"and",
"returns",
"the",
"name"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/cmd/gencudnn/conversion.go#L79-L86 |
5,444 | gorgonia/cu | blas/blas.go | Isamax | func (impl *Standard) Isamax(n int, x []float32, incX int) (retVal int) {
// declared at cublasgen.h:384:17 enum CUBLAS_STATUS { ... } cublasIsamax ...
if impl.e != nil {
return
}
if n < 0 {
panic("blas: n < 0")
}
if incX == 0 {
panic("blas: zero x index increment")
}
if n == 0 || incX < 0 {
return -1
... | go | func (impl *Standard) Isamax(n int, x []float32, incX int) (retVal int) {
// declared at cublasgen.h:384:17 enum CUBLAS_STATUS { ... } cublasIsamax ...
if impl.e != nil {
return
}
if n < 0 {
panic("blas: n < 0")
}
if incX == 0 {
panic("blas: zero x index increment")
}
if n == 0 || incX < 0 {
return -1
... | [
"func",
"(",
"impl",
"*",
"Standard",
")",
"Isamax",
"(",
"n",
"int",
",",
"x",
"[",
"]",
"float32",
",",
"incX",
"int",
")",
"(",
"retVal",
"int",
")",
"{",
"// declared at cublasgen.h:384:17 enum CUBLAS_STATUS { ... } cublasIsamax ...",
"if",
"impl",
".",
"e... | // Isamax returns the index of an element of x with the largest absolute value.
// If there are multiple such indices the earliest is returned.
// Isamax returns -1 if n == 0. | [
"Isamax",
"returns",
"the",
"index",
"of",
"an",
"element",
"of",
"x",
"with",
"the",
"largest",
"absolute",
"value",
".",
"If",
"there",
"are",
"multiple",
"such",
"indices",
"the",
"earliest",
"is",
"returned",
".",
"Isamax",
"returns",
"-",
"1",
"if",
... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/blas/blas.go#L911-L935 |
5,445 | gorgonia/cu | blas/blas.go | Idamax | func (impl *Standard) Idamax(n int, x []float64, incX int) (retVal int) {
// declared at cublasgen.h:390:17 enum CUBLAS_STATUS { ... } cublasIdamax ...
if impl.e != nil {
return
}
if n < 0 {
panic("blas: n < 0")
}
if incX == 0 {
panic("blas: zero x index increment")
}
if n == 0 || incX < 0 {
return -1
... | go | func (impl *Standard) Idamax(n int, x []float64, incX int) (retVal int) {
// declared at cublasgen.h:390:17 enum CUBLAS_STATUS { ... } cublasIdamax ...
if impl.e != nil {
return
}
if n < 0 {
panic("blas: n < 0")
}
if incX == 0 {
panic("blas: zero x index increment")
}
if n == 0 || incX < 0 {
return -1
... | [
"func",
"(",
"impl",
"*",
"Standard",
")",
"Idamax",
"(",
"n",
"int",
",",
"x",
"[",
"]",
"float64",
",",
"incX",
"int",
")",
"(",
"retVal",
"int",
")",
"{",
"// declared at cublasgen.h:390:17 enum CUBLAS_STATUS { ... } cublasIdamax ...",
"if",
"impl",
".",
"e... | // Idamax returns the index of an element of x with the largest absolute value.
// If there are multiple such indices the earliest is returned.
// Idamax returns -1 if n == 0. | [
"Idamax",
"returns",
"the",
"index",
"of",
"an",
"element",
"of",
"x",
"with",
"the",
"largest",
"absolute",
"value",
".",
"If",
"there",
"are",
"multiple",
"such",
"indices",
"the",
"earliest",
"is",
"returned",
".",
"Idamax",
"returns",
"-",
"1",
"if",
... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/blas/blas.go#L940-L964 |
5,446 | gorgonia/cu | dnn/handle.go | NewContext | func NewContext() (retVal *Context) {
var internal C.cudnnHandle_t
if err := result(C.cudnnCreate(&internal)); err != nil {
panic(err)
}
retVal = &Context{internal}
return retVal
} | go | func NewContext() (retVal *Context) {
var internal C.cudnnHandle_t
if err := result(C.cudnnCreate(&internal)); err != nil {
panic(err)
}
retVal = &Context{internal}
return retVal
} | [
"func",
"NewContext",
"(",
")",
"(",
"retVal",
"*",
"Context",
")",
"{",
"var",
"internal",
"C",
".",
"cudnnHandle_t",
"\n",
"if",
"err",
":=",
"result",
"(",
"C",
".",
"cudnnCreate",
"(",
"&",
"internal",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"p... | // NewContext creates a new Context. This is the only function that will panic if it is unable to create the context. | [
"NewContext",
"creates",
"a",
"new",
"Context",
".",
"This",
"is",
"the",
"only",
"function",
"that",
"will",
"panic",
"if",
"it",
"is",
"unable",
"to",
"create",
"the",
"context",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/handle.go#L27-L34 |
5,447 | gorgonia/cu | dnn/handle.go | Close | func (ctx *Context) Close() error {
var empty C.cudnnHandle_t
if ctx.internal == empty {
return nil
}
if err := result(C.cudnnDestroy(ctx.internal)); err != nil {
return err
}
ctx.internal = empty
return nil
} | go | func (ctx *Context) Close() error {
var empty C.cudnnHandle_t
if ctx.internal == empty {
return nil
}
if err := result(C.cudnnDestroy(ctx.internal)); err != nil {
return err
}
ctx.internal = empty
return nil
} | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"Close",
"(",
")",
"error",
"{",
"var",
"empty",
"C",
".",
"cudnnHandle_t",
"\n",
"if",
"ctx",
".",
"internal",
"==",
"empty",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"result",
"(",
"C",
... | // Close destroys the underlying context. | [
"Close",
"destroys",
"the",
"underlying",
"context",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/handle.go#L37-L48 |
5,448 | gorgonia/cu | dnn/generated_API.go | RestoreDropoutDescriptor | func (dr *Dropout) RestoreDropoutDescriptor(handle *Context, dropout float32, states Memory, stateSizeInBytes uintptr, seed uint64) error {
// call cudnnRestoreDropoutDescriptor
return result(C.cudnnRestoreDropoutDescriptor(dr.internal, handle.internal, C.float(dropout), states.Pointer(), C.size_t(stateSizeInBytes), ... | go | func (dr *Dropout) RestoreDropoutDescriptor(handle *Context, dropout float32, states Memory, stateSizeInBytes uintptr, seed uint64) error {
// call cudnnRestoreDropoutDescriptor
return result(C.cudnnRestoreDropoutDescriptor(dr.internal, handle.internal, C.float(dropout), states.Pointer(), C.size_t(stateSizeInBytes), ... | [
"func",
"(",
"dr",
"*",
"Dropout",
")",
"RestoreDropoutDescriptor",
"(",
"handle",
"*",
"Context",
",",
"dropout",
"float32",
",",
"states",
"Memory",
",",
"stateSizeInBytes",
"uintptr",
",",
"seed",
"uint64",
")",
"error",
"{",
"// call cudnnRestoreDropoutDescrip... | // RestoreDropoutDescriptor restores a dropout descriptor to a previously saved-off state. | [
"RestoreDropoutDescriptor",
"restores",
"a",
"dropout",
"descriptor",
"to",
"a",
"previously",
"saved",
"-",
"off",
"state",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L14-L17 |
5,449 | gorgonia/cu | dnn/generated_API.go | AddTensor | func (co *Context) AddTensor(alpha float64, aDesc *TensorDescriptor, A Memory, beta float64, cDesc *TensorDescriptor, C_ Memory) error {
var alphaC, betaC unsafe.Pointer
switch aDesc.dataType {
case Float, Half:
var alphaF, betaF C.float
alphaF = C.float(float32(alpha))
betaF = C.float(float32(beta))
alphaC ... | go | func (co *Context) AddTensor(alpha float64, aDesc *TensorDescriptor, A Memory, beta float64, cDesc *TensorDescriptor, C_ Memory) error {
var alphaC, betaC unsafe.Pointer
switch aDesc.dataType {
case Float, Half:
var alphaF, betaF C.float
alphaF = C.float(float32(alpha))
betaF = C.float(float32(beta))
alphaC ... | [
"func",
"(",
"co",
"*",
"Context",
")",
"AddTensor",
"(",
"alpha",
"float64",
",",
"aDesc",
"*",
"TensorDescriptor",
",",
"A",
"Memory",
",",
"beta",
"float64",
",",
"cDesc",
"*",
"TensorDescriptor",
",",
"C_",
"Memory",
")",
"error",
"{",
"var",
"alphaC... | // AddTensor adds the scaled values of a bias tensor to another tensor. Each dimension of the bias tensor A must match the corresponding dimension of the destination tensor C or must be equal to 1. In the latter case, the same value from the bias tensor for those dimensions will be used to blend into the C tensor.
// C... | [
"AddTensor",
"adds",
"the",
"scaled",
"values",
"of",
"a",
"bias",
"tensor",
"to",
"another",
"tensor",
".",
"Each",
"dimension",
"of",
"the",
"bias",
"tensor",
"A",
"must",
"match",
"the",
"corresponding",
"dimension",
"of",
"the",
"destination",
"tensor",
... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L53-L73 |
5,450 | gorgonia/cu | dnn/generated_API.go | GetReductionIndicesSize | func (co *Context) GetReductionIndicesSize(reduceTensorDesc *Reduction, aDesc *TensorDescriptor, cDesc *TensorDescriptor) (sizeInBytes uintptr, err error) {
var sizeInBytesC C.size_t
// call cudnnGetReductionIndicesSize
err = result(C.cudnnGetReductionIndicesSize(co.internal, reduceTensorDesc.internal, aDesc.interna... | go | func (co *Context) GetReductionIndicesSize(reduceTensorDesc *Reduction, aDesc *TensorDescriptor, cDesc *TensorDescriptor) (sizeInBytes uintptr, err error) {
var sizeInBytesC C.size_t
// call cudnnGetReductionIndicesSize
err = result(C.cudnnGetReductionIndicesSize(co.internal, reduceTensorDesc.internal, aDesc.interna... | [
"func",
"(",
"co",
"*",
"Context",
")",
"GetReductionIndicesSize",
"(",
"reduceTensorDesc",
"*",
"Reduction",
",",
"aDesc",
"*",
"TensorDescriptor",
",",
"cDesc",
"*",
"TensorDescriptor",
")",
"(",
"sizeInBytes",
"uintptr",
",",
"err",
"error",
")",
"{",
"var"... | // GetReductionIndicesSize is a helper function to return the minimum size of the index space to be passed to the reduction given the input and output tensors. | [
"GetReductionIndicesSize",
"is",
"a",
"helper",
"function",
"to",
"return",
"the",
"minimum",
"size",
"of",
"the",
"index",
"space",
"to",
"be",
"passed",
"to",
"the",
"reduction",
"given",
"the",
"input",
"and",
"output",
"tensors",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L104-L110 |
5,451 | gorgonia/cu | dnn/generated_API.go | ScaleTensor | func (co *Context) ScaleTensor(yDesc *TensorDescriptor, y Memory, alpha float64) error {
var alphaC unsafe.Pointer
switch yDesc.dataType {
case Float, Half:
var alphaF C.float
alphaF = C.float(float32(alpha))
alphaC = unsafe.Pointer(&alphaF)
case Double:
var alphaF C.double
alphaF = C.double(alpha)
alph... | go | func (co *Context) ScaleTensor(yDesc *TensorDescriptor, y Memory, alpha float64) error {
var alphaC unsafe.Pointer
switch yDesc.dataType {
case Float, Half:
var alphaF C.float
alphaF = C.float(float32(alpha))
alphaC = unsafe.Pointer(&alphaF)
case Double:
var alphaF C.double
alphaF = C.double(alpha)
alph... | [
"func",
"(",
"co",
"*",
"Context",
")",
"ScaleTensor",
"(",
"yDesc",
"*",
"TensorDescriptor",
",",
"y",
"Memory",
",",
"alpha",
"float64",
")",
"error",
"{",
"var",
"alphaC",
"unsafe",
".",
"Pointer",
"\n",
"switch",
"yDesc",
".",
"dataType",
"{",
"case"... | // ScaleTensor scale all the elements of a tensor by a given factor.
// y is both an input and output | [
"ScaleTensor",
"scale",
"all",
"the",
"elements",
"of",
"a",
"tensor",
"by",
"a",
"given",
"factor",
".",
"y",
"is",
"both",
"an",
"input",
"and",
"output"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L148-L164 |
5,452 | gorgonia/cu | dnn/generated_API.go | ConvolutionBackwardBias | func (co *Context) ConvolutionBackwardBias(alpha float64, dyDesc *TensorDescriptor, dy Memory, beta float64, dbDesc *TensorDescriptor, db Memory) error {
// DOUBLECHECK: "cudnnConvolutionBackwardBias" returns Memory type in Parameter 6
var alphaC, betaC unsafe.Pointer
switch dyDesc.dataType {
case Float, Half:
va... | go | func (co *Context) ConvolutionBackwardBias(alpha float64, dyDesc *TensorDescriptor, dy Memory, beta float64, dbDesc *TensorDescriptor, db Memory) error {
// DOUBLECHECK: "cudnnConvolutionBackwardBias" returns Memory type in Parameter 6
var alphaC, betaC unsafe.Pointer
switch dyDesc.dataType {
case Float, Half:
va... | [
"func",
"(",
"co",
"*",
"Context",
")",
"ConvolutionBackwardBias",
"(",
"alpha",
"float64",
",",
"dyDesc",
"*",
"TensorDescriptor",
",",
"dy",
"Memory",
",",
"beta",
"float64",
",",
"dbDesc",
"*",
"TensorDescriptor",
",",
"db",
"Memory",
")",
"error",
"{",
... | // ConvolutionBackwardBias computes the convolution function gradient with respect to the bias, which is the sum of every element belonging to the same feature map across all of the images of the input tensor. Therefore, the number of elements produced is equal to the number of features maps of the input tensor. | [
"ConvolutionBackwardBias",
"computes",
"the",
"convolution",
"function",
"gradient",
"with",
"respect",
"to",
"the",
"bias",
"which",
"is",
"the",
"sum",
"of",
"every",
"element",
"belonging",
"to",
"the",
"same",
"feature",
"map",
"across",
"all",
"of",
"the",
... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L237-L258 |
5,453 | gorgonia/cu | dnn/generated_API.go | SoftmaxForward | func (co *Context) SoftmaxForward(algo SoftmaxAlgorithm, mode SoftmaxMode, alpha float64, xDesc *TensorDescriptor, x Memory, beta float64, yDesc *TensorDescriptor, y Memory) error {
// DOUBLECHECK: "cudnnSoftmaxForward" returns Memory type in Parameter 8
var alphaC, betaC unsafe.Pointer
switch xDesc.dataType {
case... | go | func (co *Context) SoftmaxForward(algo SoftmaxAlgorithm, mode SoftmaxMode, alpha float64, xDesc *TensorDescriptor, x Memory, beta float64, yDesc *TensorDescriptor, y Memory) error {
// DOUBLECHECK: "cudnnSoftmaxForward" returns Memory type in Parameter 8
var alphaC, betaC unsafe.Pointer
switch xDesc.dataType {
case... | [
"func",
"(",
"co",
"*",
"Context",
")",
"SoftmaxForward",
"(",
"algo",
"SoftmaxAlgorithm",
",",
"mode",
"SoftmaxMode",
",",
"alpha",
"float64",
",",
"xDesc",
"*",
"TensorDescriptor",
",",
"x",
"Memory",
",",
"beta",
"float64",
",",
"yDesc",
"*",
"TensorDescr... | // SoftmaxForward computes the softmax function. | [
"SoftmaxForward",
"computes",
"the",
"softmax",
"function",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L358-L379 |
5,454 | gorgonia/cu | dnn/generated_API.go | SoftmaxBackward | func (co *Context) SoftmaxBackward(algo SoftmaxAlgorithm, mode SoftmaxMode, alpha float64, yDesc *TensorDescriptor, y Memory, dyDesc *TensorDescriptor, dy Memory, beta float64, dxDesc *TensorDescriptor, dx Memory) error {
// DOUBLECHECK: "cudnnSoftmaxBackward" returns Memory type in Parameter 10
var alphaC, betaC uns... | go | func (co *Context) SoftmaxBackward(algo SoftmaxAlgorithm, mode SoftmaxMode, alpha float64, yDesc *TensorDescriptor, y Memory, dyDesc *TensorDescriptor, dy Memory, beta float64, dxDesc *TensorDescriptor, dx Memory) error {
// DOUBLECHECK: "cudnnSoftmaxBackward" returns Memory type in Parameter 10
var alphaC, betaC uns... | [
"func",
"(",
"co",
"*",
"Context",
")",
"SoftmaxBackward",
"(",
"algo",
"SoftmaxAlgorithm",
",",
"mode",
"SoftmaxMode",
",",
"alpha",
"float64",
",",
"yDesc",
"*",
"TensorDescriptor",
",",
"y",
"Memory",
",",
"dyDesc",
"*",
"TensorDescriptor",
",",
"dy",
"Me... | // SoftmaxBackward computes the gradient of the softmax function. | [
"SoftmaxBackward",
"computes",
"the",
"gradient",
"of",
"the",
"softmax",
"function",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L382-L403 |
5,455 | gorgonia/cu | dnn/generated_API.go | LRNCrossChannelForward | func (co *Context) LRNCrossChannelForward(normDesc *LRN, lrnMode LRNMode, alpha float64, xDesc *TensorDescriptor, x Memory, beta float64, yDesc *TensorDescriptor, y Memory) error {
// DOUBLECHECK: "cudnnLRNCrossChannelForward" returns Memory type in Parameter 8
var alphaC, betaC unsafe.Pointer
switch xDesc.dataType ... | go | func (co *Context) LRNCrossChannelForward(normDesc *LRN, lrnMode LRNMode, alpha float64, xDesc *TensorDescriptor, x Memory, beta float64, yDesc *TensorDescriptor, y Memory) error {
// DOUBLECHECK: "cudnnLRNCrossChannelForward" returns Memory type in Parameter 8
var alphaC, betaC unsafe.Pointer
switch xDesc.dataType ... | [
"func",
"(",
"co",
"*",
"Context",
")",
"LRNCrossChannelForward",
"(",
"normDesc",
"*",
"LRN",
",",
"lrnMode",
"LRNMode",
",",
"alpha",
"float64",
",",
"xDesc",
"*",
"TensorDescriptor",
",",
"x",
"Memory",
",",
"beta",
"float64",
",",
"yDesc",
"*",
"Tensor... | // LRNCrossChannelForward performs the forward LRN layer computation. | [
"LRNCrossChannelForward",
"performs",
"the",
"forward",
"LRN",
"layer",
"computation",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L502-L523 |
5,456 | gorgonia/cu | dnn/generated_API.go | DivisiveNormalizationBackward | func (co *Context) DivisiveNormalizationBackward(normDesc *LRN, mode DivNormMode, alpha float64, xDesc *TensorDescriptor, x Memory, means Memory, dy Memory, temp Memory, temp2 Memory, beta float64, dXdMeansDesc *TensorDescriptor, dx Memory, dMeans Memory) error {
// DOUBLECHECK: "cudnnDivisiveNormalizationBackward" re... | go | func (co *Context) DivisiveNormalizationBackward(normDesc *LRN, mode DivNormMode, alpha float64, xDesc *TensorDescriptor, x Memory, means Memory, dy Memory, temp Memory, temp2 Memory, beta float64, dXdMeansDesc *TensorDescriptor, dx Memory, dMeans Memory) error {
// DOUBLECHECK: "cudnnDivisiveNormalizationBackward" re... | [
"func",
"(",
"co",
"*",
"Context",
")",
"DivisiveNormalizationBackward",
"(",
"normDesc",
"*",
"LRN",
",",
"mode",
"DivNormMode",
",",
"alpha",
"float64",
",",
"xDesc",
"*",
"TensorDescriptor",
",",
"x",
"Memory",
",",
"means",
"Memory",
",",
"dy",
"Memory",... | // DivisiveNormalizationBackward performs the backward DivisiveNormalization layer computation. | [
"DivisiveNormalizationBackward",
"performs",
"the",
"backward",
"DivisiveNormalization",
"layer",
"computation",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L575-L596 |
5,457 | gorgonia/cu | dnn/generated_API.go | BatchNormalizationForwardTraining | func (co *Context) BatchNormalizationForwardTraining(mode BatchNormMode, alpha float64, beta float64, xDesc *TensorDescriptor, x Memory, yDesc *TensorDescriptor, y Memory, bnScaleBiasMeanVarDesc *TensorDescriptor, bnScale Memory, bnBias Memory, exponentialAverageFactor float64, resultRunningMean Memory, resultRunningVa... | go | func (co *Context) BatchNormalizationForwardTraining(mode BatchNormMode, alpha float64, beta float64, xDesc *TensorDescriptor, x Memory, yDesc *TensorDescriptor, y Memory, bnScaleBiasMeanVarDesc *TensorDescriptor, bnScale Memory, bnBias Memory, exponentialAverageFactor float64, resultRunningMean Memory, resultRunningVa... | [
"func",
"(",
"co",
"*",
"Context",
")",
"BatchNormalizationForwardTraining",
"(",
"mode",
"BatchNormMode",
",",
"alpha",
"float64",
",",
"beta",
"float64",
",",
"xDesc",
"*",
"TensorDescriptor",
",",
"x",
"Memory",
",",
"yDesc",
"*",
"TensorDescriptor",
",",
"... | // BatchNormalizationForwardTraining performs the forward BatchNormalization layer computation for training phase. | [
"BatchNormalizationForwardTraining",
"performs",
"the",
"forward",
"BatchNormalization",
"layer",
"computation",
"for",
"training",
"phase",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L599-L620 |
5,458 | gorgonia/cu | dnn/generated_API.go | BatchNormalizationBackward | func (co *Context) BatchNormalizationBackward(mode BatchNormMode, alphaDataDiff float64, betaDataDiff float64, alphaParamDiff float64, betaParamDiff float64, xDesc *TensorDescriptor, x Memory, dyDesc *TensorDescriptor, dy Memory, dxDesc *TensorDescriptor, dx Memory, dBnScaleBiasDesc *TensorDescriptor, bnScale Memory, d... | go | func (co *Context) BatchNormalizationBackward(mode BatchNormMode, alphaDataDiff float64, betaDataDiff float64, alphaParamDiff float64, betaParamDiff float64, xDesc *TensorDescriptor, x Memory, dyDesc *TensorDescriptor, dy Memory, dxDesc *TensorDescriptor, dx Memory, dBnScaleBiasDesc *TensorDescriptor, bnScale Memory, d... | [
"func",
"(",
"co",
"*",
"Context",
")",
"BatchNormalizationBackward",
"(",
"mode",
"BatchNormMode",
",",
"alphaDataDiff",
"float64",
",",
"betaDataDiff",
"float64",
",",
"alphaParamDiff",
"float64",
",",
"betaParamDiff",
"float64",
",",
"xDesc",
"*",
"TensorDescript... | // BatchNormalizationBackward performs the backward BatchNormalization layer computation. | [
"BatchNormalizationBackward",
"performs",
"the",
"backward",
"BatchNormalization",
"layer",
"computation",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L646-L674 |
5,459 | gorgonia/cu | dnn/generated_API.go | SpatialTfGridGeneratorForward | func (co *Context) SpatialTfGridGeneratorForward(stDesc *SpatialTransformer, theta Memory, grid Memory) error {
// DOUBLECHECK: "cudnnSpatialTfGridGeneratorForward" returns Memory type in Parameter 3
// call cudnnSpatialTfGridGeneratorForward
return result(C.cudnnSpatialTfGridGeneratorForward(co.internal, stDesc.int... | go | func (co *Context) SpatialTfGridGeneratorForward(stDesc *SpatialTransformer, theta Memory, grid Memory) error {
// DOUBLECHECK: "cudnnSpatialTfGridGeneratorForward" returns Memory type in Parameter 3
// call cudnnSpatialTfGridGeneratorForward
return result(C.cudnnSpatialTfGridGeneratorForward(co.internal, stDesc.int... | [
"func",
"(",
"co",
"*",
"Context",
")",
"SpatialTfGridGeneratorForward",
"(",
"stDesc",
"*",
"SpatialTransformer",
",",
"theta",
"Memory",
",",
"grid",
"Memory",
")",
"error",
"{",
"// DOUBLECHECK: \"cudnnSpatialTfGridGeneratorForward\" returns Memory type in Parameter 3",
... | // SpatialTfGridGeneratorForward generates a grid of coordinates in the input tensor corresponding to each pixel from the output tensor. | [
"SpatialTfGridGeneratorForward",
"generates",
"a",
"grid",
"of",
"coordinates",
"in",
"the",
"input",
"tensor",
"corresponding",
"to",
"each",
"pixel",
"from",
"the",
"output",
"tensor",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L677-L681 |
5,460 | gorgonia/cu | dnn/generated_API.go | SpatialTfGridGeneratorBackward | func (co *Context) SpatialTfGridGeneratorBackward(stDesc *SpatialTransformer, dgrid Memory, dtheta Memory) error {
// DOUBLECHECK: "cudnnSpatialTfGridGeneratorBackward" returns Memory type in Parameter 3
// call cudnnSpatialTfGridGeneratorBackward
return result(C.cudnnSpatialTfGridGeneratorBackward(co.internal, stDe... | go | func (co *Context) SpatialTfGridGeneratorBackward(stDesc *SpatialTransformer, dgrid Memory, dtheta Memory) error {
// DOUBLECHECK: "cudnnSpatialTfGridGeneratorBackward" returns Memory type in Parameter 3
// call cudnnSpatialTfGridGeneratorBackward
return result(C.cudnnSpatialTfGridGeneratorBackward(co.internal, stDe... | [
"func",
"(",
"co",
"*",
"Context",
")",
"SpatialTfGridGeneratorBackward",
"(",
"stDesc",
"*",
"SpatialTransformer",
",",
"dgrid",
"Memory",
",",
"dtheta",
"Memory",
")",
"error",
"{",
"// DOUBLECHECK: \"cudnnSpatialTfGridGeneratorBackward\" returns Memory type in Parameter 3"... | // SpatialTfGridGeneratorBackward computes the gradient of a grid generation operation. | [
"SpatialTfGridGeneratorBackward",
"computes",
"the",
"gradient",
"of",
"a",
"grid",
"generation",
"operation",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L684-L688 |
5,461 | gorgonia/cu | dnn/generated_API.go | SpatialTfSamplerForward | func (co *Context) SpatialTfSamplerForward(stDesc *SpatialTransformer, alpha float64, xDesc *TensorDescriptor, x Memory, grid Memory, beta float64, yDesc *TensorDescriptor, y Memory) error {
// DOUBLECHECK: "cudnnSpatialTfSamplerForward" returns Memory type in Parameter 8
var alphaC, betaC unsafe.Pointer
switch xDes... | go | func (co *Context) SpatialTfSamplerForward(stDesc *SpatialTransformer, alpha float64, xDesc *TensorDescriptor, x Memory, grid Memory, beta float64, yDesc *TensorDescriptor, y Memory) error {
// DOUBLECHECK: "cudnnSpatialTfSamplerForward" returns Memory type in Parameter 8
var alphaC, betaC unsafe.Pointer
switch xDes... | [
"func",
"(",
"co",
"*",
"Context",
")",
"SpatialTfSamplerForward",
"(",
"stDesc",
"*",
"SpatialTransformer",
",",
"alpha",
"float64",
",",
"xDesc",
"*",
"TensorDescriptor",
",",
"x",
"Memory",
",",
"grid",
"Memory",
",",
"beta",
"float64",
",",
"yDesc",
"*",... | // SpatialTfSamplerForward performs a sampler operation and generates the output tensor using the grid given by the grid generator. | [
"SpatialTfSamplerForward",
"performs",
"a",
"sampler",
"operation",
"and",
"generates",
"the",
"output",
"tensor",
"using",
"the",
"grid",
"given",
"by",
"the",
"grid",
"generator",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L691-L712 |
5,462 | gorgonia/cu | dnn/generated_API.go | SpatialTfSamplerBackward | func (co *Context) SpatialTfSamplerBackward(stDesc *SpatialTransformer, alpha float64, xDesc *TensorDescriptor, x Memory, beta float64, dxDesc *TensorDescriptor, dx Memory, alphaDgrid Memory, dyDesc *TensorDescriptor, dy Memory, grid Memory, betaDgrid Memory, dgrid Memory) error {
// DOUBLECHECK: "cudnnSpatialTfSample... | go | func (co *Context) SpatialTfSamplerBackward(stDesc *SpatialTransformer, alpha float64, xDesc *TensorDescriptor, x Memory, beta float64, dxDesc *TensorDescriptor, dx Memory, alphaDgrid Memory, dyDesc *TensorDescriptor, dy Memory, grid Memory, betaDgrid Memory, dgrid Memory) error {
// DOUBLECHECK: "cudnnSpatialTfSample... | [
"func",
"(",
"co",
"*",
"Context",
")",
"SpatialTfSamplerBackward",
"(",
"stDesc",
"*",
"SpatialTransformer",
",",
"alpha",
"float64",
",",
"xDesc",
"*",
"TensorDescriptor",
",",
"x",
"Memory",
",",
"beta",
"float64",
",",
"dxDesc",
"*",
"TensorDescriptor",
",... | // SpatialTfSamplerBackward computes the gradient of a sampling operation. | [
"SpatialTfSamplerBackward",
"computes",
"the",
"gradient",
"of",
"a",
"sampling",
"operation",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L715-L736 |
5,463 | gorgonia/cu | dnn/generated_API.go | DropoutGetStatesSize | func (co *Context) DropoutGetStatesSize() (sizeInBytes uintptr, err error) {
var sizeInBytesC C.size_t
// call cudnnDropoutGetStatesSize
err = result(C.cudnnDropoutGetStatesSize(co.internal, &sizeInBytesC))
sizeInBytes = uintptr(sizeInBytesC)
return
} | go | func (co *Context) DropoutGetStatesSize() (sizeInBytes uintptr, err error) {
var sizeInBytesC C.size_t
// call cudnnDropoutGetStatesSize
err = result(C.cudnnDropoutGetStatesSize(co.internal, &sizeInBytesC))
sizeInBytes = uintptr(sizeInBytesC)
return
} | [
"func",
"(",
"co",
"*",
"Context",
")",
"DropoutGetStatesSize",
"(",
")",
"(",
"sizeInBytes",
"uintptr",
",",
"err",
"error",
")",
"{",
"var",
"sizeInBytesC",
"C",
".",
"size_t",
"\n",
"// call cudnnDropoutGetStatesSize",
"err",
"=",
"result",
"(",
"C",
".",... | // DropoutGetStatesSize is used to query the amount of space required to store the states of the random number generators used by cudnnDropoutForward function. | [
"DropoutGetStatesSize",
"is",
"used",
"to",
"query",
"the",
"amount",
"of",
"space",
"required",
"to",
"store",
"the",
"states",
"of",
"the",
"random",
"number",
"generators",
"used",
"by",
"cudnnDropoutForward",
"function",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L739-L745 |
5,464 | gorgonia/cu | dnn/generated_API.go | DropoutBackward | func (co *Context) DropoutBackward(dropoutDesc *Dropout, dydesc *TensorDescriptor, dy Memory, dxdesc *TensorDescriptor, dx Memory, reserveSpace Memory, reserveSpaceSizeInBytes uintptr) error {
// DOUBLECHECK: "cudnnDropoutBackward" returns Memory type in Parameter 5
// call cudnnDropoutBackward
return result(C.cudnn... | go | func (co *Context) DropoutBackward(dropoutDesc *Dropout, dydesc *TensorDescriptor, dy Memory, dxdesc *TensorDescriptor, dx Memory, reserveSpace Memory, reserveSpaceSizeInBytes uintptr) error {
// DOUBLECHECK: "cudnnDropoutBackward" returns Memory type in Parameter 5
// call cudnnDropoutBackward
return result(C.cudnn... | [
"func",
"(",
"co",
"*",
"Context",
")",
"DropoutBackward",
"(",
"dropoutDesc",
"*",
"Dropout",
",",
"dydesc",
"*",
"TensorDescriptor",
",",
"dy",
"Memory",
",",
"dxdesc",
"*",
"TensorDescriptor",
",",
"dx",
"Memory",
",",
"reserveSpace",
"Memory",
",",
"rese... | // DropoutBackward performs backward dropout operation over dy returning results in dx. If during forward dropout operation value from x was propagated to y then during backward operation value from dy will be propagated to dx, otherwise, dx value will be set to 0. | [
"DropoutBackward",
"performs",
"backward",
"dropout",
"operation",
"over",
"dy",
"returning",
"results",
"in",
"dx",
".",
"If",
"during",
"forward",
"dropout",
"operation",
"value",
"from",
"x",
"was",
"propagated",
"to",
"y",
"then",
"during",
"backward",
"oper... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L755-L759 |
5,465 | gorgonia/cu | dnn/generated_API.go | GetRNNWorkspaceSize | func (co *Context) GetRNNWorkspaceSize(rnnDesc *RNN, seqLength int, xDesc []*TensorDescriptor) (sizeInBytes uintptr, err error) {
var sizeInBytesC C.size_t
if len(xDesc) != seqLength {
return 0, errors.Errorf("Incorrect xDesc length. Want %d. Got %d", seqLength, len(xDesc))
}
internals := make([]C.cudnnTensorDes... | go | func (co *Context) GetRNNWorkspaceSize(rnnDesc *RNN, seqLength int, xDesc []*TensorDescriptor) (sizeInBytes uintptr, err error) {
var sizeInBytesC C.size_t
if len(xDesc) != seqLength {
return 0, errors.Errorf("Incorrect xDesc length. Want %d. Got %d", seqLength, len(xDesc))
}
internals := make([]C.cudnnTensorDes... | [
"func",
"(",
"co",
"*",
"Context",
")",
"GetRNNWorkspaceSize",
"(",
"rnnDesc",
"*",
"RNN",
",",
"seqLength",
"int",
",",
"xDesc",
"[",
"]",
"*",
"TensorDescriptor",
")",
"(",
"sizeInBytes",
"uintptr",
",",
"err",
"error",
")",
"{",
"var",
"sizeInBytesC",
... | // GetRNNWorkspaceSize is used to query the amount of work space required to execute the RNN described by rnnDesc with inputs dimensions defined by xDesc. | [
"GetRNNWorkspaceSize",
"is",
"used",
"to",
"query",
"the",
"amount",
"of",
"work",
"space",
"required",
"to",
"execute",
"the",
"RNN",
"described",
"by",
"rnnDesc",
"with",
"inputs",
"dimensions",
"defined",
"by",
"xDesc",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L762-L778 |
5,466 | gorgonia/cu | dnn/generated_API.go | GetRNNParamsSize | func (co *Context) GetRNNParamsSize(rnnDesc *RNN, xDesc *TensorDescriptor, dataType DataType) (sizeInBytes uintptr, err error) {
var sizeInBytesC C.size_t
// call cudnnGetRNNParamsSize
err = result(C.cudnnGetRNNParamsSize(co.internal, rnnDesc.internal, xDesc.internal, &sizeInBytesC, dataType.C()))
sizeInBytes = uin... | go | func (co *Context) GetRNNParamsSize(rnnDesc *RNN, xDesc *TensorDescriptor, dataType DataType) (sizeInBytes uintptr, err error) {
var sizeInBytesC C.size_t
// call cudnnGetRNNParamsSize
err = result(C.cudnnGetRNNParamsSize(co.internal, rnnDesc.internal, xDesc.internal, &sizeInBytesC, dataType.C()))
sizeInBytes = uin... | [
"func",
"(",
"co",
"*",
"Context",
")",
"GetRNNParamsSize",
"(",
"rnnDesc",
"*",
"RNN",
",",
"xDesc",
"*",
"TensorDescriptor",
",",
"dataType",
"DataType",
")",
"(",
"sizeInBytes",
"uintptr",
",",
"err",
"error",
")",
"{",
"var",
"sizeInBytesC",
"C",
".",
... | // GetRNNParamsSize is used to query the amount of parameter space required to execute the RNN described by rnnDesc with inputs dimensions defined by xDesc. | [
"GetRNNParamsSize",
"is",
"used",
"to",
"query",
"the",
"amount",
"of",
"parameter",
"space",
"required",
"to",
"execute",
"the",
"RNN",
"described",
"by",
"rnnDesc",
"with",
"inputs",
"dimensions",
"defined",
"by",
"xDesc",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L800-L806 |
5,467 | gorgonia/cu | dnn/generated_API.go | RNNBackwardData | func (co *Context) RNNBackwardData(rnnDesc *RNN, seqLength int, yDesc []*TensorDescriptor, y Memory, dyDesc []*TensorDescriptor, dy Memory, dhyDesc *TensorDescriptor, dhy Memory, dcyDesc *TensorDescriptor, dcy Memory, wDesc *Filter, w Memory, hxDesc *TensorDescriptor, hx Memory, cxDesc *TensorDescriptor, cx Memory, dxD... | go | func (co *Context) RNNBackwardData(rnnDesc *RNN, seqLength int, yDesc []*TensorDescriptor, y Memory, dyDesc []*TensorDescriptor, dy Memory, dhyDesc *TensorDescriptor, dhy Memory, dcyDesc *TensorDescriptor, dcy Memory, wDesc *Filter, w Memory, hxDesc *TensorDescriptor, hx Memory, cxDesc *TensorDescriptor, cx Memory, dxD... | [
"func",
"(",
"co",
"*",
"Context",
")",
"RNNBackwardData",
"(",
"rnnDesc",
"*",
"RNN",
",",
"seqLength",
"int",
",",
"yDesc",
"[",
"]",
"*",
"TensorDescriptor",
",",
"y",
"Memory",
",",
"dyDesc",
"[",
"]",
"*",
"TensorDescriptor",
",",
"dy",
"Memory",
... | // RNNBackwardData executes the recurrent neural network described by rnnDesc with output gradients dy, dhy, dhc, weights w and input gradients dx, dhx, dcx. workspace is required for intermediate storage. The data in reserveSpace must have previously been generated by cudnnRNNForwardTraining. The same reserveSpace dat... | [
"RNNBackwardData",
"executes",
"the",
"recurrent",
"neural",
"network",
"described",
"by",
"rnnDesc",
"with",
"output",
"gradients",
"dy",
"dhy",
"dhc",
"weights",
"w",
"and",
"input",
"gradients",
"dx",
"dhx",
"dcx",
".",
"workspace",
"is",
"required",
"for",
... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L870-L892 |
5,468 | gorgonia/cu | dnn/generated_API.go | RNNBackwardWeights | func (co *Context) RNNBackwardWeights(rnnDesc *RNN, seqLength int, xDesc []*TensorDescriptor, x Memory, hxDesc *TensorDescriptor, hx Memory, yDesc []*TensorDescriptor, y Memory, workspace Memory, workSpaceSizeInBytes uintptr, dwDesc *Filter, dw Memory, reserveSpace Memory, reserveSpaceSizeInBytes uintptr) error {
inte... | go | func (co *Context) RNNBackwardWeights(rnnDesc *RNN, seqLength int, xDesc []*TensorDescriptor, x Memory, hxDesc *TensorDescriptor, hx Memory, yDesc []*TensorDescriptor, y Memory, workspace Memory, workSpaceSizeInBytes uintptr, dwDesc *Filter, dw Memory, reserveSpace Memory, reserveSpaceSizeInBytes uintptr) error {
inte... | [
"func",
"(",
"co",
"*",
"Context",
")",
"RNNBackwardWeights",
"(",
"rnnDesc",
"*",
"RNN",
",",
"seqLength",
"int",
",",
"xDesc",
"[",
"]",
"*",
"TensorDescriptor",
",",
"x",
"Memory",
",",
"hxDesc",
"*",
"TensorDescriptor",
",",
"hx",
"Memory",
",",
"yDe... | // RNNBackwardWeights accumulates weight gradients dw from the recurrent neural network described by rnnDesc with inputs x, hx, and outputs y. The mode of operation in this case is additive, the weight gradients calculated will be added to those already existing in dw. workspace is required for intermediate storage. Th... | [
"RNNBackwardWeights",
"accumulates",
"weight",
"gradients",
"dw",
"from",
"the",
"recurrent",
"neural",
"network",
"described",
"by",
"rnnDesc",
"with",
"inputs",
"x",
"hx",
"and",
"outputs",
"y",
".",
"The",
"mode",
"of",
"operation",
"in",
"this",
"case",
"i... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L896-L911 |
5,469 | gorgonia/cu | dnn/generated_API.go | CTCLoss | func (co *Context) CTCLoss(probsDesc *TensorDescriptor, probs Memory, labels []int, labelLengths []int, inputLengths []int, costs Memory, gradientsDesc *TensorDescriptor, gradients Memory, algo CTCLossAlgo, ctcLossDesc *CTCLoss, workspace Memory, workSpaceSizeInBytes uintptr) error {
// DOUBLECHECK: "cudnnCTCLoss" ret... | go | func (co *Context) CTCLoss(probsDesc *TensorDescriptor, probs Memory, labels []int, labelLengths []int, inputLengths []int, costs Memory, gradientsDesc *TensorDescriptor, gradients Memory, algo CTCLossAlgo, ctcLossDesc *CTCLoss, workspace Memory, workSpaceSizeInBytes uintptr) error {
// DOUBLECHECK: "cudnnCTCLoss" ret... | [
"func",
"(",
"co",
"*",
"Context",
")",
"CTCLoss",
"(",
"probsDesc",
"*",
"TensorDescriptor",
",",
"probs",
"Memory",
",",
"labels",
"[",
"]",
"int",
",",
"labelLengths",
"[",
"]",
"int",
",",
"inputLengths",
"[",
"]",
"int",
",",
"costs",
"Memory",
",... | // CTCLoss returns the ctc costs and gradients, given the probabilities and labels. | [
"CTCLoss",
"returns",
"the",
"ctc",
"costs",
"and",
"gradients",
"given",
"the",
"probabilities",
"and",
"labels",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_API.go#L914-L925 |
5,470 | gorgonia/cu | batchedPatterns.go | LaunchAndSync | func (fn Function) LaunchAndSync(gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes int, stream Stream, kernelParams []unsafe.Pointer) error {
argv := C.malloc(C.size_t(len(kernelParams) * pointerSize))
argp := C.malloc(C.size_t(len(kernelParams) * pointerSize))
defer C.free(argv)
defer C... | go | func (fn Function) LaunchAndSync(gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes int, stream Stream, kernelParams []unsafe.Pointer) error {
argv := C.malloc(C.size_t(len(kernelParams) * pointerSize))
argp := C.malloc(C.size_t(len(kernelParams) * pointerSize))
defer C.free(argv)
defer C... | [
"func",
"(",
"fn",
"Function",
")",
"LaunchAndSync",
"(",
"gridDimX",
",",
"gridDimY",
",",
"gridDimZ",
",",
"blockDimX",
",",
"blockDimY",
",",
"blockDimZ",
",",
"sharedMemBytes",
"int",
",",
"stream",
"Stream",
",",
"kernelParams",
"[",
"]",
"unsafe",
".",... | // LaunchAndSync launches the kernel and synchronizes the context | [
"LaunchAndSync",
"launches",
"the",
"kernel",
"and",
"synchronizes",
"the",
"context"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batchedPatterns.go#L37-L60 |
5,471 | gorgonia/cu | batchedPatterns.go | AllocAndCopy | func AllocAndCopy(p unsafe.Pointer, bytesize int64) (DevicePtr, error) {
if bytesize == 0 {
return 0, errors.Wrapf(InvalidValue, "Cannot allocate memory with size 0")
}
var d C.CUdeviceptr
if err := result(C.cuAllocAndCopy(&d, p, C.size_t(bytesize))); err != nil {
return 0, errors.Wrapf(err, "AllocAndCopy")
}... | go | func AllocAndCopy(p unsafe.Pointer, bytesize int64) (DevicePtr, error) {
if bytesize == 0 {
return 0, errors.Wrapf(InvalidValue, "Cannot allocate memory with size 0")
}
var d C.CUdeviceptr
if err := result(C.cuAllocAndCopy(&d, p, C.size_t(bytesize))); err != nil {
return 0, errors.Wrapf(err, "AllocAndCopy")
}... | [
"func",
"AllocAndCopy",
"(",
"p",
"unsafe",
".",
"Pointer",
",",
"bytesize",
"int64",
")",
"(",
"DevicePtr",
",",
"error",
")",
"{",
"if",
"bytesize",
"==",
"0",
"{",
"return",
"0",
",",
"errors",
".",
"Wrapf",
"(",
"InvalidValue",
",",
"\"",
"\"",
"... | // AllocAndCopy abstracts away the common pattern of allocating and then copying a Go slice to the GPU | [
"AllocAndCopy",
"abstracts",
"away",
"the",
"common",
"pattern",
"of",
"allocating",
"and",
"then",
"copying",
"a",
"Go",
"slice",
"to",
"the",
"GPU"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batchedPatterns.go#L63-L73 |
5,472 | gorgonia/cu | batch.go | NewBatchedContext | func NewBatchedContext(c Context, d Device) *BatchedContext {
return &BatchedContext{
Context: c,
Device: d,
workAvailable: make(chan struct{}, 1),
work: make(chan call, workBufLen),
queue: make([]call, 0, workBufLen),
fns: make([]C.uintptr_t, 0, workBufLen),
results: m... | go | func NewBatchedContext(c Context, d Device) *BatchedContext {
return &BatchedContext{
Context: c,
Device: d,
workAvailable: make(chan struct{}, 1),
work: make(chan call, workBufLen),
queue: make([]call, 0, workBufLen),
fns: make([]C.uintptr_t, 0, workBufLen),
results: m... | [
"func",
"NewBatchedContext",
"(",
"c",
"Context",
",",
"d",
"Device",
")",
"*",
"BatchedContext",
"{",
"return",
"&",
"BatchedContext",
"{",
"Context",
":",
"c",
",",
"Device",
":",
"d",
",",
"workAvailable",
":",
"make",
"(",
"chan",
"struct",
"{",
"}",... | // NewBatchedContext creates a batched CUDA context. | [
"NewBatchedContext",
"creates",
"a",
"batched",
"CUDA",
"context",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batch.go#L154-L168 |
5,473 | gorgonia/cu | batch.go | Run | func (ctx *BatchedContext) Run(errChan chan error) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
for {
select {
case <-ctx.workAvailable:
ctx.DoWork()
if err := ctx.Errors(); err != nil {
if errChan == nil {
return err
}
errChan <- err
}
case w := <-ctx.Work():
ctx... | go | func (ctx *BatchedContext) Run(errChan chan error) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
for {
select {
case <-ctx.workAvailable:
ctx.DoWork()
if err := ctx.Errors(); err != nil {
if errChan == nil {
return err
}
errChan <- err
}
case w := <-ctx.Work():
ctx... | [
"func",
"(",
"ctx",
"*",
"BatchedContext",
")",
"Run",
"(",
"errChan",
"chan",
"error",
")",
"error",
"{",
"runtime",
".",
"LockOSThread",
"(",
")",
"\n",
"defer",
"runtime",
".",
"UnlockOSThread",
"(",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"<-... | // Run manages the running of the BatchedContext. Because it's expected to run in a goroutine, an error channel is to be passed in | [
"Run",
"manages",
"the",
"running",
"of",
"the",
"BatchedContext",
".",
"Because",
"it",
"s",
"expected",
"to",
"run",
"in",
"a",
"goroutine",
"an",
"error",
"channel",
"is",
"to",
"be",
"passed",
"in"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batch.go#L272-L290 |
5,474 | gorgonia/cu | batch.go | Cleanup | func (ctx *BatchedContext) Cleanup() {
for i, f := range ctx.frees {
C.free(f)
ctx.frees[i] = nil
}
ctx.frees = ctx.frees[:0]
} | go | func (ctx *BatchedContext) Cleanup() {
for i, f := range ctx.frees {
C.free(f)
ctx.frees[i] = nil
}
ctx.frees = ctx.frees[:0]
} | [
"func",
"(",
"ctx",
"*",
"BatchedContext",
")",
"Cleanup",
"(",
")",
"{",
"for",
"i",
",",
"f",
":=",
"range",
"ctx",
".",
"frees",
"{",
"C",
".",
"free",
"(",
"f",
")",
"\n",
"ctx",
".",
"frees",
"[",
"i",
"]",
"=",
"nil",
"\n",
"}",
"\n",
... | // Cleanup is the cleanup function. It cleans up all the ancilliary allocations that has happened for all the batched calls.
// This method should be called when the context is done with - otherwise there'd be a lot of leaked memory.
//
// The main reason why this method exists is because there is no way to reliably fr... | [
"Cleanup",
"is",
"the",
"cleanup",
"function",
".",
"It",
"cleans",
"up",
"all",
"the",
"ancilliary",
"allocations",
"that",
"has",
"happened",
"for",
"all",
"the",
"batched",
"calls",
".",
"This",
"method",
"should",
"be",
"called",
"when",
"the",
"context"... | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batch.go#L296-L302 |
5,475 | gorgonia/cu | batch.go | Close | func (ctx *BatchedContext) Close() error {
ctx.initialized = false
return ctx.Context.Close()
} | go | func (ctx *BatchedContext) Close() error {
ctx.initialized = false
return ctx.Context.Close()
} | [
"func",
"(",
"ctx",
"*",
"BatchedContext",
")",
"Close",
"(",
")",
"error",
"{",
"ctx",
".",
"initialized",
"=",
"false",
"\n",
"return",
"ctx",
".",
"Context",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Close closes the batched context | [
"Close",
"closes",
"the",
"batched",
"context"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batch.go#L305-L308 |
5,476 | gorgonia/cu | batch.go | FirstError | func (ctx *BatchedContext) FirstError() error {
for i, v := range ctx.results {
if cuResult(v) != Success {
return result(v)
}
ctx.results[i] = C.CUDA_SUCCESS
}
return nil
} | go | func (ctx *BatchedContext) FirstError() error {
for i, v := range ctx.results {
if cuResult(v) != Success {
return result(v)
}
ctx.results[i] = C.CUDA_SUCCESS
}
return nil
} | [
"func",
"(",
"ctx",
"*",
"BatchedContext",
")",
"FirstError",
"(",
")",
"error",
"{",
"for",
"i",
",",
"v",
":=",
"range",
"ctx",
".",
"results",
"{",
"if",
"cuResult",
"(",
"v",
")",
"!=",
"Success",
"{",
"return",
"result",
"(",
"v",
")",
"\n",
... | // FirstError returns the first error if there was any | [
"FirstError",
"returns",
"the",
"first",
"error",
"if",
"there",
"was",
"any"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batch.go#L314-L322 |
5,477 | gorgonia/cu | batch.go | SetCurrent | func (ctx *BatchedContext) SetCurrent() {
fn := &fnargs{
fn: C.fn_setCurrent,
ctx: ctx.CUDAContext().ctx,
}
c := call{fn, false}
ctx.enqueue(c)
} | go | func (ctx *BatchedContext) SetCurrent() {
fn := &fnargs{
fn: C.fn_setCurrent,
ctx: ctx.CUDAContext().ctx,
}
c := call{fn, false}
ctx.enqueue(c)
} | [
"func",
"(",
"ctx",
"*",
"BatchedContext",
")",
"SetCurrent",
"(",
")",
"{",
"fn",
":=",
"&",
"fnargs",
"{",
"fn",
":",
"C",
".",
"fn_setCurrent",
",",
"ctx",
":",
"ctx",
".",
"CUDAContext",
"(",
")",
".",
"ctx",
",",
"}",
"\n",
"c",
":=",
"call"... | // SetCurrent sets the current context. This is usually unnecessary because SetCurrent will be called before batch processing the calls. | [
"SetCurrent",
"sets",
"the",
"current",
"context",
".",
"This",
"is",
"usually",
"unnecessary",
"because",
"SetCurrent",
"will",
"be",
"called",
"before",
"batch",
"processing",
"the",
"calls",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batch.go#L325-L332 |
5,478 | gorgonia/cu | batch.go | MemAlloc | func (ctx *BatchedContext) MemAlloc(bytesize int64) (retVal DevicePtr, err error) {
fn := &fnargs{
fn: C.fn_mallocD,
size: C.size_t(bytesize),
}
c := call{fn, true}
return ctx.enqueue(c)
} | go | func (ctx *BatchedContext) MemAlloc(bytesize int64) (retVal DevicePtr, err error) {
fn := &fnargs{
fn: C.fn_mallocD,
size: C.size_t(bytesize),
}
c := call{fn, true}
return ctx.enqueue(c)
} | [
"func",
"(",
"ctx",
"*",
"BatchedContext",
")",
"MemAlloc",
"(",
"bytesize",
"int64",
")",
"(",
"retVal",
"DevicePtr",
",",
"err",
"error",
")",
"{",
"fn",
":=",
"&",
"fnargs",
"{",
"fn",
":",
"C",
".",
"fn_mallocD",
",",
"size",
":",
"C",
".",
"si... | // MemAlloc allocates memory. It is a blocking call. | [
"MemAlloc",
"allocates",
"memory",
".",
"It",
"is",
"a",
"blocking",
"call",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batch.go#L335-L342 |
5,479 | gorgonia/cu | batch.go | errors | func (ctx *BatchedContext) errors() error {
if !ctx.checkResults() {
return nil
}
err := make(errorSlice, len(ctx.results))
for i, res := range ctx.results {
err[i] = result(res)
}
return err
} | go | func (ctx *BatchedContext) errors() error {
if !ctx.checkResults() {
return nil
}
err := make(errorSlice, len(ctx.results))
for i, res := range ctx.results {
err[i] = result(res)
}
return err
} | [
"func",
"(",
"ctx",
"*",
"BatchedContext",
")",
"errors",
"(",
")",
"error",
"{",
"if",
"!",
"ctx",
".",
"checkResults",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"err",
":=",
"make",
"(",
"errorSlice",
",",
"len",
"(",
"ctx",
".",
"results"... | // errors convert ctx.results into errors | [
"errors",
"convert",
"ctx",
".",
"results",
"into",
"errors"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batch.go#L470-L479 |
5,480 | gorgonia/cu | batch.go | introspect | func (ctx *BatchedContext) introspect() string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "Queue: %d", len(ctx.queue))
for _, v := range ctx.queue {
fmt.Fprintf(&buf, "\n\t[QUEUE] %s", v.fnargs)
}
return buf.String()
} | go | func (ctx *BatchedContext) introspect() string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "Queue: %d", len(ctx.queue))
for _, v := range ctx.queue {
fmt.Fprintf(&buf, "\n\t[QUEUE] %s", v.fnargs)
}
return buf.String()
} | [
"func",
"(",
"ctx",
"*",
"BatchedContext",
")",
"introspect",
"(",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"fmt",
".",
"Fprintf",
"(",
"&",
"buf",
",",
"\"",
"\"",
",",
"len",
"(",
"ctx",
".",
"queue",
")",
")",
"\n",
"for... | // introspect is useful for finding out what calls are going to be made in the batched call | [
"introspect",
"is",
"useful",
"for",
"finding",
"out",
"what",
"calls",
"are",
"going",
"to",
"be",
"made",
"in",
"the",
"batched",
"call"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/batch.go#L482-L489 |
5,481 | gorgonia/cu | dnn/generated_lrn.go | NewLRN | func NewLRN(lrnN uint, lrnAlpha float64, lrnBeta float64, lrnK float64) (retVal *LRN, err error) {
var internal C.cudnnLRNDescriptor_t
if err := result(C.cudnnCreateLRNDescriptor(&internal)); err != nil {
return nil, err
}
if err := result(C.cudnnSetLRNDescriptor(internal, C.uint(lrnN), C.double(lrnAlpha), C.dou... | go | func NewLRN(lrnN uint, lrnAlpha float64, lrnBeta float64, lrnK float64) (retVal *LRN, err error) {
var internal C.cudnnLRNDescriptor_t
if err := result(C.cudnnCreateLRNDescriptor(&internal)); err != nil {
return nil, err
}
if err := result(C.cudnnSetLRNDescriptor(internal, C.uint(lrnN), C.double(lrnAlpha), C.dou... | [
"func",
"NewLRN",
"(",
"lrnN",
"uint",
",",
"lrnAlpha",
"float64",
",",
"lrnBeta",
"float64",
",",
"lrnK",
"float64",
")",
"(",
"retVal",
"*",
"LRN",
",",
"err",
"error",
")",
"{",
"var",
"internal",
"C",
".",
"cudnnLRNDescriptor_t",
"\n",
"if",
"err",
... | // NewLRN creates a new LRN. | [
"NewLRN",
"creates",
"a",
"new",
"LRN",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_lrn.go#L20-L39 |
5,482 | gorgonia/cu | addressing.go | PtrAttribute | func (d DevicePtr) PtrAttribute(attr PointerAttribute) (unsafe.Pointer, error) {
var p unsafe.Pointer
devPtr := C.CUdeviceptr(d)
a := C.CUpointer_attribute(attr)
if err := result(C.cuPointerGetAttribute(p, a, devPtr)); err != nil {
return nil, err
}
return p, nil
} | go | func (d DevicePtr) PtrAttribute(attr PointerAttribute) (unsafe.Pointer, error) {
var p unsafe.Pointer
devPtr := C.CUdeviceptr(d)
a := C.CUpointer_attribute(attr)
if err := result(C.cuPointerGetAttribute(p, a, devPtr)); err != nil {
return nil, err
}
return p, nil
} | [
"func",
"(",
"d",
"DevicePtr",
")",
"PtrAttribute",
"(",
"attr",
"PointerAttribute",
")",
"(",
"unsafe",
".",
"Pointer",
",",
"error",
")",
"{",
"var",
"p",
"unsafe",
".",
"Pointer",
"\n",
"devPtr",
":=",
"C",
".",
"CUdeviceptr",
"(",
"d",
")",
"\n",
... | // PtrAttribute returns information about a pointer. | [
"PtrAttribute",
"returns",
"information",
"about",
"a",
"pointer",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/addressing.go#L90-L98 |
5,483 | gorgonia/cu | instrumentation.go | AverageQueueLength | func AverageQueueLength() int {
ql.Lock()
var s int
for _, l := range q {
s += l
}
avg := s / len(q) // yes, it's an integer division
ql.Unlock()
return avg
} | go | func AverageQueueLength() int {
ql.Lock()
var s int
for _, l := range q {
s += l
}
avg := s / len(q) // yes, it's an integer division
ql.Unlock()
return avg
} | [
"func",
"AverageQueueLength",
"(",
")",
"int",
"{",
"ql",
".",
"Lock",
"(",
")",
"\n",
"var",
"s",
"int",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"q",
"{",
"s",
"+=",
"l",
"\n",
"}",
"\n",
"avg",
":=",
"s",
"/",
"len",
"(",
"q",
")",
"//... | // AverageQueueLength returns the average queue length recorded. This allows for optimizations. | [
"AverageQueueLength",
"returns",
"the",
"average",
"queue",
"length",
"recorded",
".",
"This",
"allows",
"for",
"optimizations",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/instrumentation.go#L47-L56 |
5,484 | gorgonia/cu | dnn/generated_ctcloss.go | NewCTCLoss | func NewCTCLoss(compType DataType) (retVal *CTCLoss, err error) {
var internal C.cudnnCTCLossDescriptor_t
if err := result(C.cudnnCreateCTCLossDescriptor(&internal)); err != nil {
return nil, err
}
if err := result(C.cudnnSetCTCLossDescriptor(internal, compType.C())); err != nil {
return nil, err
}
retVal =... | go | func NewCTCLoss(compType DataType) (retVal *CTCLoss, err error) {
var internal C.cudnnCTCLossDescriptor_t
if err := result(C.cudnnCreateCTCLossDescriptor(&internal)); err != nil {
return nil, err
}
if err := result(C.cudnnSetCTCLossDescriptor(internal, compType.C())); err != nil {
return nil, err
}
retVal =... | [
"func",
"NewCTCLoss",
"(",
"compType",
"DataType",
")",
"(",
"retVal",
"*",
"CTCLoss",
",",
"err",
"error",
")",
"{",
"var",
"internal",
"C",
".",
"cudnnCTCLossDescriptor_t",
"\n",
"if",
"err",
":=",
"result",
"(",
"C",
".",
"cudnnCreateCTCLossDescriptor",
"... | // NewCTCLoss creates a new CTCLoss. | [
"NewCTCLoss",
"creates",
"a",
"new",
"CTCLoss",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/generated_ctcloss.go#L17-L33 |
5,485 | gorgonia/cu | ctx_debug.go | NewContext | func NewContext(d Device, flags ContextFlags) *Ctx {
var cctx C.CUcontext
err := result(C.cuCtxCreate(&cctx, C.uint(flags), C.CUdevice(d)))
if err != nil {
panic(err)
}
ctx := newContext(makeContext(cctx))
ctx.device = d
ctx.flags = flags
errChan := make(chan error)
go ctx.Run(errChan)
if err := <-errChan;... | go | func NewContext(d Device, flags ContextFlags) *Ctx {
var cctx C.CUcontext
err := result(C.cuCtxCreate(&cctx, C.uint(flags), C.CUdevice(d)))
if err != nil {
panic(err)
}
ctx := newContext(makeContext(cctx))
ctx.device = d
ctx.flags = flags
errChan := make(chan error)
go ctx.Run(errChan)
if err := <-errChan;... | [
"func",
"NewContext",
"(",
"d",
"Device",
",",
"flags",
"ContextFlags",
")",
"*",
"Ctx",
"{",
"var",
"cctx",
"C",
".",
"CUcontext",
"\n",
"err",
":=",
"result",
"(",
"C",
".",
"cuCtxCreate",
"(",
"&",
"cctx",
",",
"C",
".",
"uint",
"(",
"flags",
")... | // NewContext creates a new context, and runs a listener locked to an OSThread. All work is piped through that goroutine | [
"NewContext",
"creates",
"a",
"new",
"context",
"and",
"runs",
"a",
"listener",
"locked",
"to",
"an",
"OSThread",
".",
"All",
"work",
"is",
"piped",
"through",
"that",
"goroutine"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/ctx_debug.go#L25-L42 |
5,486 | gorgonia/cu | module.go | LoadData | func LoadData(image string) (Module, error) {
var mod Module
cstr := C.CString(image)
defer C.free(unsafe.Pointer(cstr))
err := result(C.cuModuleLoadData(&mod.mod, unsafe.Pointer(cstr)))
return mod, err
} | go | func LoadData(image string) (Module, error) {
var mod Module
cstr := C.CString(image)
defer C.free(unsafe.Pointer(cstr))
err := result(C.cuModuleLoadData(&mod.mod, unsafe.Pointer(cstr)))
return mod, err
} | [
"func",
"LoadData",
"(",
"image",
"string",
")",
"(",
"Module",
",",
"error",
")",
"{",
"var",
"mod",
"Module",
"\n",
"cstr",
":=",
"C",
".",
"CString",
"(",
"image",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cstr",... | // LoadData loads a module from a input string. | [
"LoadData",
"loads",
"a",
"module",
"from",
"a",
"input",
"string",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/module.go#L32-L38 |
5,487 | gorgonia/cu | module.go | LoadDataEx | func LoadDataEx(image string, options ...JITOption) (Module, error) {
var mod Module
cstr := C.CString(image)
defer C.free(unsafe.Pointer(cstr))
argcount, args, argvals := encodeArguments(options)
err := result(C.cuModuleLoadDataEx(&mod.mod, unsafe.Pointer(cstr), argcount, args, argvals))
return mod, err
} | go | func LoadDataEx(image string, options ...JITOption) (Module, error) {
var mod Module
cstr := C.CString(image)
defer C.free(unsafe.Pointer(cstr))
argcount, args, argvals := encodeArguments(options)
err := result(C.cuModuleLoadDataEx(&mod.mod, unsafe.Pointer(cstr), argcount, args, argvals))
return mod, err
} | [
"func",
"LoadDataEx",
"(",
"image",
"string",
",",
"options",
"...",
"JITOption",
")",
"(",
"Module",
",",
"error",
")",
"{",
"var",
"mod",
"Module",
"\n",
"cstr",
":=",
"C",
".",
"CString",
"(",
"image",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
... | // LoadDataEx loads a module from a input string. | [
"LoadDataEx",
"loads",
"a",
"module",
"from",
"a",
"input",
"string",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/module.go#L41-L49 |
5,488 | gorgonia/cu | module.go | LoadFatBinary | func LoadFatBinary(image string) (Module, error) {
var mod Module
cstr := C.CString(image)
defer C.free(unsafe.Pointer(cstr))
err := result(C.cuModuleLoadFatBinary(&mod.mod, unsafe.Pointer(cstr)))
return mod, err
} | go | func LoadFatBinary(image string) (Module, error) {
var mod Module
cstr := C.CString(image)
defer C.free(unsafe.Pointer(cstr))
err := result(C.cuModuleLoadFatBinary(&mod.mod, unsafe.Pointer(cstr)))
return mod, err
} | [
"func",
"LoadFatBinary",
"(",
"image",
"string",
")",
"(",
"Module",
",",
"error",
")",
"{",
"var",
"mod",
"Module",
"\n",
"cstr",
":=",
"C",
".",
"CString",
"(",
"image",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"c... | // LoadFatBinary loads a module from a input string. | [
"LoadFatBinary",
"loads",
"a",
"module",
"from",
"a",
"input",
"string",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/module.go#L52-L58 |
5,489 | gorgonia/cu | module.go | Function | func (m Module) Function(name string) (Function, error) {
var fn Function
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
err := result(C.cuModuleGetFunction(&fn.fn, m.mod, cstr))
return fn, err
} | go | func (m Module) Function(name string) (Function, error) {
var fn Function
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
err := result(C.cuModuleGetFunction(&fn.fn, m.mod, cstr))
return fn, err
} | [
"func",
"(",
"m",
"Module",
")",
"Function",
"(",
"name",
"string",
")",
"(",
"Function",
",",
"error",
")",
"{",
"var",
"fn",
"Function",
"\n",
"cstr",
":=",
"C",
".",
"CString",
"(",
"name",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
... | // Function returns a pointer to the function in the module by the name. If it's not found, the error NotFound is returned | [
"Function",
"returns",
"a",
"pointer",
"to",
"the",
"function",
"in",
"the",
"module",
"by",
"the",
"name",
".",
"If",
"it",
"s",
"not",
"found",
"the",
"error",
"NotFound",
"is",
"returned"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/module.go#L61-L67 |
5,490 | gorgonia/cu | module.go | Global | func (m Module) Global(name string) (DevicePtr, int64, error) {
var d C.CUdeviceptr
var size C.size_t
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
if err := result(C.cuModuleGetGlobal(&d, &size, m.mod, cstr)); err != nil {
return 0, 0, err
}
return DevicePtr(d), int64(size), nil
} | go | func (m Module) Global(name string) (DevicePtr, int64, error) {
var d C.CUdeviceptr
var size C.size_t
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
if err := result(C.cuModuleGetGlobal(&d, &size, m.mod, cstr)); err != nil {
return 0, 0, err
}
return DevicePtr(d), int64(size), nil
} | [
"func",
"(",
"m",
"Module",
")",
"Global",
"(",
"name",
"string",
")",
"(",
"DevicePtr",
",",
"int64",
",",
"error",
")",
"{",
"var",
"d",
"C",
".",
"CUdeviceptr",
"\n",
"var",
"size",
"C",
".",
"size_t",
"\n",
"cstr",
":=",
"C",
".",
"CString",
... | // Global returns a global pointer as defined in a module. It returns a pointer to the memory in the device. | [
"Global",
"returns",
"a",
"global",
"pointer",
"as",
"defined",
"in",
"a",
"module",
".",
"It",
"returns",
"a",
"pointer",
"to",
"the",
"memory",
"in",
"the",
"device",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/module.go#L70-L79 |
5,491 | gorgonia/cu | jit.go | NewLink | func NewLink(options ...JITOption) (*LinkState, error) {
link := &LinkState{}
argcount, args, argvals := link.encodeArguments(options)
err := result(C.cuLinkCreate(argcount, args, argvals, &link.state))
return link, err
} | go | func NewLink(options ...JITOption) (*LinkState, error) {
link := &LinkState{}
argcount, args, argvals := link.encodeArguments(options)
err := result(C.cuLinkCreate(argcount, args, argvals, &link.state))
return link, err
} | [
"func",
"NewLink",
"(",
"options",
"...",
"JITOption",
")",
"(",
"*",
"LinkState",
",",
"error",
")",
"{",
"link",
":=",
"&",
"LinkState",
"{",
"}",
"\n\n",
"argcount",
",",
"args",
",",
"argvals",
":=",
"link",
".",
"encodeArguments",
"(",
"options",
... | // Creates a pending JIT linker invocation. | [
"Creates",
"a",
"pending",
"JIT",
"linker",
"invocation",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/jit.go#L190-L196 |
5,492 | gorgonia/cu | jit.go | AddData | func (link *LinkState) AddData(input JITInputType, data string, name string, options ...JITOption) error {
argcount, args, argvals := link.encodeArguments(options)
cname := C.CString(name)
bytes := []byte(data)
err := result(C.cuLinkAddData(
link.state, C.CUjitInputType(input),
unsafe.Pointer(&bytes[0]), C.siz... | go | func (link *LinkState) AddData(input JITInputType, data string, name string, options ...JITOption) error {
argcount, args, argvals := link.encodeArguments(options)
cname := C.CString(name)
bytes := []byte(data)
err := result(C.cuLinkAddData(
link.state, C.CUjitInputType(input),
unsafe.Pointer(&bytes[0]), C.siz... | [
"func",
"(",
"link",
"*",
"LinkState",
")",
"AddData",
"(",
"input",
"JITInputType",
",",
"data",
"string",
",",
"name",
"string",
",",
"options",
"...",
"JITOption",
")",
"error",
"{",
"argcount",
",",
"args",
",",
"argvals",
":=",
"link",
".",
"encodeA... | // Add an input to a pending linker invocation | [
"Add",
"an",
"input",
"to",
"a",
"pending",
"linker",
"invocation"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/jit.go#L223-L236 |
5,493 | gorgonia/cu | jit.go | AddFile | func (link *LinkState) AddFile(input JITInputType, path string, options ...JITOption) error {
argcount, args, argvals := link.encodeArguments(options)
cpath := C.CString(path)
err := result(C.cuLinkAddFile(
link.state, C.CUjitInputType(input),
cpath,
argcount, args, argvals,
))
C.free(unsafe.Pointer(cpath))... | go | func (link *LinkState) AddFile(input JITInputType, path string, options ...JITOption) error {
argcount, args, argvals := link.encodeArguments(options)
cpath := C.CString(path)
err := result(C.cuLinkAddFile(
link.state, C.CUjitInputType(input),
cpath,
argcount, args, argvals,
))
C.free(unsafe.Pointer(cpath))... | [
"func",
"(",
"link",
"*",
"LinkState",
")",
"AddFile",
"(",
"input",
"JITInputType",
",",
"path",
"string",
",",
"options",
"...",
"JITOption",
")",
"error",
"{",
"argcount",
",",
"args",
",",
"argvals",
":=",
"link",
".",
"encodeArguments",
"(",
"options"... | // Add a file input to a pending linker invocation | [
"Add",
"a",
"file",
"input",
"to",
"a",
"pending",
"linker",
"invocation"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/jit.go#L239-L250 |
5,494 | gorgonia/cu | jit.go | Complete | func (link *LinkState) Complete() (string, error) {
var data unsafe.Pointer
var datasize C.size_t
err := result(C.cuLinkComplete(link.state, &data, &datasize))
if err != nil {
return "", err
}
size := int(datasize)
buffer := make([]byte, size)
copy(buffer, (*[20 << 30]byte)(data)[:size])
return string(buf... | go | func (link *LinkState) Complete() (string, error) {
var data unsafe.Pointer
var datasize C.size_t
err := result(C.cuLinkComplete(link.state, &data, &datasize))
if err != nil {
return "", err
}
size := int(datasize)
buffer := make([]byte, size)
copy(buffer, (*[20 << 30]byte)(data)[:size])
return string(buf... | [
"func",
"(",
"link",
"*",
"LinkState",
")",
"Complete",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"data",
"unsafe",
".",
"Pointer",
"\n",
"var",
"datasize",
"C",
".",
"size_t",
"\n\n",
"err",
":=",
"result",
"(",
"C",
".",
"cuLinkComple... | // Complete a pending linker invocation | [
"Complete",
"a",
"pending",
"linker",
"invocation"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/jit.go#L253-L267 |
5,495 | gorgonia/cu | cmd/gencudnn/parse.go | functions | func functions(decl *cc.Declarator) bool {
if !strings.HasPrefix(bindgen.NameOf(decl), "cudnn") {
return false
}
if decl.Type.Kind() == cc.Function {
return true
}
return false
} | go | func functions(decl *cc.Declarator) bool {
if !strings.HasPrefix(bindgen.NameOf(decl), "cudnn") {
return false
}
if decl.Type.Kind() == cc.Function {
return true
}
return false
} | [
"func",
"functions",
"(",
"decl",
"*",
"cc",
".",
"Declarator",
")",
"bool",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"bindgen",
".",
"NameOf",
"(",
"decl",
")",
",",
"\"",
"\"",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"decl",
... | // Functions returns the C function declarations in the givel set of file paths. | [
"Functions",
"returns",
"the",
"C",
"function",
"declarations",
"in",
"the",
"givel",
"set",
"of",
"file",
"paths",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/cmd/gencudnn/parse.go#L12-L21 |
5,496 | gorgonia/cu | cmd/gencudnn/parse.go | goNameOfStr | func goNameOfStr(n string) (retVal string) {
var ok bool
defer func() {
retVal = reqPtr(retVal)
}()
if retVal, ok = ctypes2GoTypes[n]; ok {
return retVal
}
if retVal, ok = enumMappings[n]; ok {
return retVal
}
if retVal, ok = builtins[n]; ok {
return retVal
}
if retVal, ok = nonPrimitives[n]; ok {
r... | go | func goNameOfStr(n string) (retVal string) {
var ok bool
defer func() {
retVal = reqPtr(retVal)
}()
if retVal, ok = ctypes2GoTypes[n]; ok {
return retVal
}
if retVal, ok = enumMappings[n]; ok {
return retVal
}
if retVal, ok = builtins[n]; ok {
return retVal
}
if retVal, ok = nonPrimitives[n]; ok {
r... | [
"func",
"goNameOfStr",
"(",
"n",
"string",
")",
"(",
"retVal",
"string",
")",
"{",
"var",
"ok",
"bool",
"\n",
"defer",
"func",
"(",
")",
"{",
"retVal",
"=",
"reqPtr",
"(",
"retVal",
")",
"\n",
"}",
"(",
")",
"\n",
"if",
"retVal",
",",
"ok",
"=",
... | // same as above, but given a c name type in string | [
"same",
"as",
"above",
"but",
"given",
"a",
"c",
"name",
"type",
"in",
"string"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/cmd/gencudnn/parse.go#L190-L209 |
5,497 | gorgonia/cu | dnn/rnn.go | NewRNN | func (handle *Context) NewRNN(hiddenSize int, numLayers int, dropout *Dropout, inputMode RNNInputMode, direction DirectionMode, mode RNNMode, algo RNNAlgo, dataType DataType) (retVal *RNN, err error) {
var internal C.cudnnRNNDescriptor_t
if err := result(C.cudnnCreateRNNDescriptor(&internal)); err != nil {
return n... | go | func (handle *Context) NewRNN(hiddenSize int, numLayers int, dropout *Dropout, inputMode RNNInputMode, direction DirectionMode, mode RNNMode, algo RNNAlgo, dataType DataType) (retVal *RNN, err error) {
var internal C.cudnnRNNDescriptor_t
if err := result(C.cudnnCreateRNNDescriptor(&internal)); err != nil {
return n... | [
"func",
"(",
"handle",
"*",
"Context",
")",
"NewRNN",
"(",
"hiddenSize",
"int",
",",
"numLayers",
"int",
",",
"dropout",
"*",
"Dropout",
",",
"inputMode",
"RNNInputMode",
",",
"direction",
"DirectionMode",
",",
"mode",
"RNNMode",
",",
"algo",
"RNNAlgo",
",",... | // NewRNN creates a new RNN. | [
"NewRNN",
"creates",
"a",
"new",
"RNN",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/rnn.go#L61-L86 |
5,498 | gorgonia/cu | dnn/dropout.go | NewDropout | func NewDropout(dropout float64) (retVal *Dropout, err error) {
var internal C.cudnnDropoutDescriptor_t
if err := result(C.cudnnCreateDropoutDescriptor(&internal)); err != nil {
return nil, err
}
retVal = &Dropout{
internal: internal,
dropout: float32(dropout),
}
runtime.SetFinalizer(retVal, destroyDropout... | go | func NewDropout(dropout float64) (retVal *Dropout, err error) {
var internal C.cudnnDropoutDescriptor_t
if err := result(C.cudnnCreateDropoutDescriptor(&internal)); err != nil {
return nil, err
}
retVal = &Dropout{
internal: internal,
dropout: float32(dropout),
}
runtime.SetFinalizer(retVal, destroyDropout... | [
"func",
"NewDropout",
"(",
"dropout",
"float64",
")",
"(",
"retVal",
"*",
"Dropout",
",",
"err",
"error",
")",
"{",
"var",
"internal",
"C",
".",
"cudnnDropoutDescriptor_t",
"\n",
"if",
"err",
":=",
"result",
"(",
"C",
".",
"cudnnCreateDropoutDescriptor",
"("... | // NewDropout creates a Dropout descriptor. It is not usable by default because some additional stateful information needs to be passed in | [
"NewDropout",
"creates",
"a",
"Dropout",
"descriptor",
".",
"It",
"is",
"not",
"usable",
"by",
"default",
"because",
"some",
"additional",
"stateful",
"information",
"needs",
"to",
"be",
"passed",
"in"
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/dropout.go#L35-L46 |
5,499 | gorgonia/cu | dnn/dropout.go | Use | func (d *Dropout) Use(ctx *Context, states Memory, stateSizeInBytes uintptr, seed uint64) error {
d.handle = ctx
d.states = states
d.stateSizeInBytes = stateSizeInBytes
d.seed = seed
return result(C.cudnnSetDropoutDescriptor(d.internal, d.handle.internal, C.float(d.dropout), unsafe.Pointer(d.states.Uintptr()), C.... | go | func (d *Dropout) Use(ctx *Context, states Memory, stateSizeInBytes uintptr, seed uint64) error {
d.handle = ctx
d.states = states
d.stateSizeInBytes = stateSizeInBytes
d.seed = seed
return result(C.cudnnSetDropoutDescriptor(d.internal, d.handle.internal, C.float(d.dropout), unsafe.Pointer(d.states.Uintptr()), C.... | [
"func",
"(",
"d",
"*",
"Dropout",
")",
"Use",
"(",
"ctx",
"*",
"Context",
",",
"states",
"Memory",
",",
"stateSizeInBytes",
"uintptr",
",",
"seed",
"uint64",
")",
"error",
"{",
"d",
".",
"handle",
"=",
"ctx",
"\n",
"d",
".",
"states",
"=",
"states",
... | // Use is the second stage of the two-stage API. | [
"Use",
"is",
"the",
"second",
"stage",
"of",
"the",
"two",
"-",
"stage",
"API",
"."
] | 89152d7e441439045736bc7640ff607ec371c26c | https://github.com/gorgonia/cu/blob/89152d7e441439045736bc7640ff607ec371c26c/dnn/dropout.go#L58-L65 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.