Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML-110] Update isOAPEnabled for Kmeans, PCA & ALS #113

Merged
merged 1 commit into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ class KMeans @Since("1.5.0") (

val isPlatformSupported = Utils.checkClusterPlatformCompatibility(
dataset.sparkSession.sparkContext)
val useKMeansDAL = isPlatformSupported && $(distanceMeasure) == "euclidean" && !handleWeight
val useKMeansDAL = Utils.isOAPEnabled() && isPlatformSupported &&
$(distanceMeasure) == "euclidean" && !handleWeight

val model = if (useKMeansDAL) {
trainWithDAL(instances, handlePersistence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,11 @@ class PCA @Since("1.5.0") (
require($(k) <= numFeatures,
s"source vector size $numFeatures must be no less than k=$k")

val sc = dataset.sparkSession.sparkContext
val isPlatformSupported = Utils.checkClusterPlatformCompatibility(
dataset.sparkSession.sparkContext)

// Call oneDAL Correlation PCA implementation when numFeatures < 65535 and fall back otherwise
val parentModel = if (numFeatures < 65535 && isPlatformSupported) {
val parentModel = if (numFeatures < 65535 && Utils.isOAPEnabled() && isPlatformSupported) {
val executor_num = Utils.sparkExecutorNum(dataset.sparkSession.sparkContext)
val executor_cores = Utils.sparkExecutorCores()
val pca = new PCADALImpl(k = $(k), executor_num, executor_cores)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ object ALS extends DefaultParamsReadable[ALS] with Logging {
val isPlatformSupported = DALImplUtils.checkClusterPlatformCompatibility(ratings.sparkContext)

val (userIdAndFactors, itemIdAndFactors) =
if (implicitPrefs && isPlatformSupported) {
if (implicitPrefs && DALImplUtils.isOAPEnabled() && isPlatformSupported) {
new ALSDALImpl(ratings, rank, maxIter, regParam, alpha, seed).train()
} else {
trainMLlib(ratings, rank, numUserBlocks, numItemBlocks, maxIter, regParam, implicitPrefs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ class KMeans @Since("1.5.0") (

val isPlatformSupported = Utils.checkClusterPlatformCompatibility(
dataset.sparkSession.sparkContext)
val useKMeansDAL = isPlatformSupported && $(distanceMeasure) == "euclidean" && !handleWeight
val useKMeansDAL = Utils.isOAPEnabled() && isPlatformSupported &&
$(distanceMeasure) == "euclidean" && !handleWeight

val model = if (useKMeansDAL) {
trainWithDAL(instances, handlePersistence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,11 @@ class PCA @Since("1.5.0") (
require($(k) <= numFeatures,
s"source vector size $numFeatures must be no less than k=$k")

val sc = dataset.sparkSession.sparkContext
val isPlatformSupported = Utils.checkClusterPlatformCompatibility(
dataset.sparkSession.sparkContext)

// Call oneDAL Correlation PCA implementation when numFeatures < 65535 and fall back otherwise
val parentModel = if (numFeatures < 65535 && isPlatformSupported) {
val parentModel = if (numFeatures < 65535 && Utils.isOAPEnabled() && isPlatformSupported) {
val executor_num = Utils.sparkExecutorNum(dataset.sparkSession.sparkContext)
val executor_cores = Utils.sparkExecutorCores()
val pca = new PCADALImpl(k = $(k), executor_num, executor_cores)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ object ALS extends DefaultParamsReadable[ALS] with Logging {
val isPlatformSupported = DALImplUtils.checkClusterPlatformCompatibility(ratings.sparkContext)

val (userIdAndFactors, itemIdAndFactors) =
if (implicitPrefs && isPlatformSupported) {
if (implicitPrefs && DALImplUtils.isOAPEnabled() && isPlatformSupported) {
new ALSDALImpl(ratings, rank, maxIter, regParam, alpha, seed).train()
} else {
trainMLlib(ratings, rank, numUserBlocks, numItemBlocks, maxIter, regParam, implicitPrefs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ class KMeans @Since("1.5.0") (

val isPlatformSupported = Utils.checkClusterPlatformCompatibility(
dataset.sparkSession.sparkContext)
val useKMeansDAL = isPlatformSupported && $(distanceMeasure) == "euclidean" && !handleWeight
val useKMeansDAL = Utils.isOAPEnabled() && isPlatformSupported &&
$(distanceMeasure) == "euclidean" && !handleWeight

val model = if (useKMeansDAL) {
trainWithDAL(instances, handlePersistence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,11 @@ class PCA @Since("1.5.0") (
require($(k) <= numFeatures,
s"source vector size $numFeatures must be no less than k=$k")

val sc = dataset.sparkSession.sparkContext
val isPlatformSupported = Utils.checkClusterPlatformCompatibility(
dataset.sparkSession.sparkContext)

// Call oneDAL Correlation PCA implementation when numFeatures < 65535 and fall back otherwise
val parentModel = if (numFeatures < 65535 && isPlatformSupported) {
val parentModel = if (numFeatures < 65535 && Utils.isOAPEnabled() && isPlatformSupported) {
val executor_num = Utils.sparkExecutorNum(dataset.sparkSession.sparkContext)
val executor_cores = Utils.sparkExecutorCores()
val pca = new PCADALImpl(k = $(k), executor_num, executor_cores)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ object ALS extends DefaultParamsReadable[ALS] with Logging {
val isPlatformSupported = DALImplUtils.checkClusterPlatformCompatibility(ratings.sparkContext)

val (userIdAndFactors, itemIdAndFactors) =
if (implicitPrefs && isPlatformSupported) {
if (implicitPrefs && DALImplUtils.isOAPEnabled() && isPlatformSupported) {
new ALSDALImpl(ratings, rank, maxIter, regParam, alpha, seed).train()
} else {
trainMLlib(ratings, rank, numUserBlocks, numItemBlocks, maxIter, regParam, implicitPrefs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ class KMeans @Since("1.5.0") (

val isPlatformSupported = Utils.checkClusterPlatformCompatibility(
dataset.sparkSession.sparkContext)
val useKMeansDAL = isPlatformSupported && $(distanceMeasure) == "euclidean" && !handleWeight
val useKMeansDAL = Utils.isOAPEnabled() && isPlatformSupported &&
$(distanceMeasure) == "euclidean" && !handleWeight

val model = if (useKMeansDAL) {
trainWithDAL(instances, handlePersistence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,11 @@ class PCA @Since("1.5.0") (
require($(k) <= numFeatures,
s"source vector size $numFeatures must be no less than k=$k")

val sc = dataset.sparkSession.sparkContext
val isPlatformSupported = Utils.checkClusterPlatformCompatibility(
dataset.sparkSession.sparkContext)

// Call oneDAL Correlation PCA implementation when numFeatures < 65535 and fall back otherwise
val parentModel = if (numFeatures < 65535 && isPlatformSupported) {
val parentModel = if (numFeatures < 65535 && Utils.isOAPEnabled() && isPlatformSupported) {
val executor_num = Utils.sparkExecutorNum(dataset.sparkSession.sparkContext)
val executor_cores = Utils.sparkExecutorCores()
val pca = new PCADALImpl(k = $(k), executor_num, executor_cores)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ object ALS extends DefaultParamsReadable[ALS] with Logging {
val isPlatformSupported = DALImplUtils.checkClusterPlatformCompatibility(ratings.sparkContext)

val (userIdAndFactors, itemIdAndFactors) =
if (implicitPrefs && isPlatformSupported) {
if (implicitPrefs && DALImplUtils.isOAPEnabled() && isPlatformSupported) {
new ALSDALImpl(ratings, rank, maxIter, regParam, alpha, seed).train()
} else {
trainMLlib(ratings, rank, numUserBlocks, numItemBlocks, maxIter, regParam, implicitPrefs,
Expand Down