Skip to content

Commit

Permalink
DistriOptimizerV2 argument (intel-analytics#3003)
Browse files Browse the repository at this point in the history
* call DistriOptimizerV2
  • Loading branch information
Le-Zheng authored May 27, 2020
1 parent af64ee9 commit c3e20d8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Engine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ sealed trait EngineType
case object MklBlas extends EngineType
case object MklDnn extends EngineType

/**
* define optimizer version trait
*/
sealed trait OptimizerVersion

case object OptimizerV1 extends OptimizerVersion
case object OptimizerV2 extends OptimizerVersion


object Engine {

Expand Down Expand Up @@ -215,6 +223,18 @@ object Engine {
}
}

/**
* Notice: Please use property bigdl.optimizerVersion to set optimizerVersion.
* Default version is OptimizerV1
*/
private var optimizerVersion: OptimizerVersion = {
System.getProperty("bigdl.optimizerVersion", "optimizerv1").toLowerCase(Locale.ROOT) match {
case "optimizerv1" => OptimizerV1
case "optimizerv2" => OptimizerV2
case optimizerVersion => throw new IllegalArgumentException(s"Unknown type $optimizerVersion")
}
}

// Thread pool for default use
@volatile private var _default: ThreadPool = null

Expand Down Expand Up @@ -314,6 +334,19 @@ object Engine {
nodeNum = n
}

/**
* This method should only be used for test purpose.
*
* @param optimizerVersion
*/
private[bigdl] def setOptimizerVersion(optimizerVersion : OptimizerVersion): Unit = {
this.optimizerVersion = optimizerVersion
}

private[bigdl] def getOptimizerVersion(): OptimizerVersion = {
this.optimizerVersion
}

/**
* This method should only be used for test purpose.
*
Expand Down

0 comments on commit c3e20d8

Please sign in to comment.