Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lanking520 committed Dec 5, 2018
1 parent 5ef1ee0 commit a6673b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ class Classifier(modelPathPrefix: String,
: IndexedSeq[IndexedSeq[(String, Float)]] = {

// considering only the first output
// Copy NDArray to CPU to avoid frequent GPU to CPU copying
val predictResultND: NDArray =
predictor.predictWithNDArray(input)(0).asInContext(Context.cpu())

// Parallel Execution with ParArray for better performance
val predictResultPar: ParArray[Array[Float]] =
new ParArray[Array[Float]](predictResultND.shape(0))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ class ObjectDetector(modelPathPrefix: String,
def objectDetectWithNDArray(input: IndexedSeq[NDArray], topK: Option[Int])
: IndexedSeq[IndexedSeq[(String, Array[Float])]] = {

// Copy NDArray to CPU to avoid frequent GPU to CPU copying
val predictResult = predictor.predictWithNDArray(input)(0).asInContext(Context.cpu())
// Parallel Execution with ParArray for better performance
var batchResult = new ParArray[IndexedSeq[(String, Array[Float])]](predictResult.shape(0))
(0 until predictResult.shape(0)).toArray.par.foreach( i => {
val r = predictResult.at(i)
Expand Down

0 comments on commit a6673b5

Please sign in to comment.