MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / LoadSavedModel

Function LoadSavedModel

tensorflow/go/saved_model.go:48–74  ·  view source on GitHub ↗

LoadSavedModel creates a new SavedModel from a model previously exported to a directory on disk. Exported models contain a set of graphs and, optionally, variable values. Tags in the model identify a single graph. LoadSavedModel initializes a session with the identified graph and with variables ini

(exportDir string, tags []string, options *SessionOptions)

Source from the content-addressed store, hash-verified

46// See:
47// https://www.tensorflow.org/code/tensorflow/python/saved_model/
48func LoadSavedModel(exportDir string, tags []string, options *SessionOptions) (*SavedModel, error) {
49 status := newStatus()
50 cOpt, doneOpt, err := options.c()
51 defer doneOpt()
52 if err != nil {
53 return nil, err
54 }
55 cExportDir := C.CString(exportDir)
56 cTags := make([]*C.char, len(tags))
57 for i := range tags {
58 cTags[i] = C.CString(tags[i])
59 }
60 graph := NewGraph()
61 // TODO(jhseu): Add support for run_options and meta_graph_def.
62 cSess := C.TF_LoadSessionFromSavedModel(cOpt, nil, cExportDir, (**C.char)(unsafe.Pointer(&cTags[0])), C.int(len(cTags)), graph.c, nil, status.c)
63 for i := range cTags {
64 C.free(unsafe.Pointer(cTags[i]))
65 }
66 C.free(unsafe.Pointer(cExportDir))
67
68 if err := status.Err(); err != nil {
69 return nil, err
70 }
71 s := &Session{c: cSess}
72 runtime.SetFinalizer(s, func(s *Session) { s.Close() })
73 return &SavedModel{Session: s, Graph: graph}, nil
74}

Callers 3

TestSavedModelFunction · 0.70
InitMethod · 0.50

Calls 7

CloseMethod · 0.95
newStatusFunction · 0.85
makeFunction · 0.85
NewGraphFunction · 0.85
freeMethod · 0.80
cMethod · 0.45
ErrMethod · 0.45

Tested by 1

TestSavedModelFunction · 0.56