Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: minmingzhu <minming.zhu@intel.com>
  • Loading branch information
minmingzhu committed Aug 4, 2023
1 parent d01d422 commit 38d370a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mllib-dal/src/main/scala/com/intel/oap/mllib/OneDAL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,12 @@ object OneDAL {
val coalescedTables = coalescedRdd.mapPartitionsWithIndex { (index: Int, it: Iterator[Row]) =>
val list = it.toList
val subRowCount: Int = list.size / numberCores
val labeledPointsList: ListBuffer[Future[(Array[Double], Long)]] =
new ListBuffer[Future[(Array[Double], Long)]]()
val labeledPointsList: ListBuffer[Future[(Array[Float], Long)]] =
new ListBuffer[Future[(Array[Float], Long)]]()
val numRows = list.size
val numCols = list(0).getAs[Vector](1).toArray.size

val labelsArray = new Array[Double](numRows)
val labelsArray = new Array[Float](numRows)
val featuresAddress= OneDAL.cNewFloatArray(numRows.toLong * numCols)
for ( i <- 0 until numberCores) {
val f = Future {
Expand All @@ -463,8 +463,8 @@ object OneDAL {
}
slice.toArray.zipWithIndex.map { case (row, index) =>
val length = row.getAs[Vector](1).toArray.length
OneDAL.cCopyArrayToNative(featuresAddress, row.getAs[Vector](1).toArray, subRowCount.toLong * numCols * i + length * index)
labelsArray(subRowCount * i + index) = row.getAs[Double](0)
OneDAL.cCopyArrayToNative(featuresAddress, row.getAs[Vector](1).toArray.map(_.toFloat), subRowCount.toLong * numCols * i + length * index)
labelsArray(subRowCount * i + index) = row.getAs[Float](0)
}
(labelsArray, featuresAddress)
}
Expand Down Expand Up @@ -636,7 +636,7 @@ object OneDAL {
}
slice.toArray.zipWithIndex.map { case (vector, index) =>
val length = vector.toArray.length
OneDAL.cCopyArrayToNative(targetArrayAddress, vector.toArray, subRowCount.toLong * numCols * i + length * index)
OneDAL.cCopyArrayToNative(targetArrayAddress, vector.toArray.map(_.toFloat), subRowCount.toLong * numCols * i + length * index)
}
targetArrayAddress
}
Expand Down

0 comments on commit 38d370a

Please sign in to comment.