TFLoadAndPredict generates PAI-TF prediction program.
(ir *ir.PredictStmt, session *pb.Session, modelPath string)
| 76 | |
| 77 | // TFLoadAndPredict generates PAI-TF prediction program. |
| 78 | func TFLoadAndPredict(ir *ir.PredictStmt, session *pb.Session, modelPath string) (string, error) { |
| 79 | var tpl = template.Must(template.New("Predict").Parse(tfPredictTmplText)) |
| 80 | ossModelDir := OSSModelURL(modelPath) |
| 81 | paiPredictTable := "" |
| 82 | if tensorflow.IsPAI() && ir.TmpPredictTable != "" { |
| 83 | paiPredictTable = ir.TmpPredictTable |
| 84 | } |
| 85 | filler := predictFiller{ |
| 86 | OSSModelDir: ossModelDir, |
| 87 | DataSource: session.DbConnStr, |
| 88 | Select: ir.Select, |
| 89 | ResultTable: ir.ResultTable, |
| 90 | ResultColumn: ir.ResultColumn, |
| 91 | PAITable: paiPredictTable, |
| 92 | Using: ir.Using, |
| 93 | } |
| 94 | var code bytes.Buffer |
| 95 | if err := tpl.Execute(&code, filler); err != nil { |
| 96 | return "", err |
| 97 | } |
| 98 | return code.String(), nil |
| 99 | } |
| 100 | |
| 101 | // TFLoadAndExplain generates PAI-TF explain program. |
| 102 | func TFLoadAndExplain(ir *ir.ExplainStmt, session *pb.Session, modelPath string, expn *ExplainRender) (string, error) { |
no test coverage detected