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

Commit

Permalink
add one more class to convert Strings to DTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
lanking520 committed Jul 25, 2018
1 parent 4ce87dd commit c3d75bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ object DType extends Enumeration {
case DType.Unknown => 0
}
}
private[mxnet] def getType(dtypeStr: String): DType = {
dtypeStr match {
case "UInt8" => DType.UInt8
case "Int32" => DType.Int32
case "Float16" => DType.Float16
case "Float32" => DType.Float32
case "Float64" => DType.Float64
}
}
}
5 changes: 2 additions & 3 deletions scala-package/core/src/main/scala/org/apache/mxnet/IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory
import scala.annotation.varargs
import scala.collection.immutable.ListMap
import scala.collection.mutable.ListBuffer
import scala.reflect.runtime.universe._
/**
* IO iterators for loading training & validation data
*/
Expand Down Expand Up @@ -112,8 +111,8 @@ object IO {
val labelDType = params.getOrElse("labelDType", "Int32")
new MXDataIter(out.value, dataName, labelName,
dataLayout = dataLayout, labelLayout = labelLayout,
dataDType = q"DType ${TermName(dataDType)}".asInstanceOf[DType],
labelDType = q"DType ${TermName(labelDType)}".asInstanceOf[DType])
dataDType = DType.getType(dataDType),
labelDType = DType.getType(labelDType))
}

// Convert data into canonical form.
Expand Down

0 comments on commit c3d75bd

Please sign in to comment.