Skip to content

Commit 392dceb

Browse files
authored
Fixed some parts in renaming ML related stuff (#839)
* Fixed renaming * Fixed renaming * Fixed renaming * Comment dependency
1 parent 24fe475 commit 392dceb

File tree

23 files changed

+89
-86
lines changed

23 files changed

+89
-86
lines changed

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jsoup_version=1.7.2
4444
djl_api_version=0.17.0
4545
pytorch_native_version=1.9.1
4646
shadow_jar_version=7.1.2
47+
openblas_version=0.3.10-1.5.4
48+
arpack_ng_version=3.7.0-1.5.4
4749
# soot also depends on asm, so there could be two different versions
4850

4951
org.gradle.daemon=false

utbot-analytics-torch/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ dependencies {
1616
testImplementation project(':utbot-sample')
1717
testImplementation group: 'junit', name: 'junit', version: junit4_version
1818

19-
implementation group: 'org.bytedeco', name: 'arpack-ng', version: "3.7.0-1.5.4", classifier: "$classifier"
20-
implementation group: 'org.bytedeco', name: 'openblas', version: "0.3.10-1.5.4", classifier: "$classifier"
2119
implementation group: 'org.bytedeco', name: 'javacpp', version: javacpp_version, classifier: "$classifier"
2220
implementation group: 'org.jsoup', name: 'jsoup', version: jsoup_version
2321

utbot-analytics-torch/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
To enable support of the `utbot-analytics-torch` models in `utbot-intellij` module the following steps should be made:
22

3-
- change the row `api project(':utbot-analytics-torch')` to the `api project(':utbot-analytics-torch')` in the `build.gradle` file in the `utbot-intellij` module
3+
- change the row `api project(':utbot-analytics')` to the `api project(':utbot-analytics-torch')` in the `build.gradle` file in the `utbot-intellij` module and uncomment it, if it's commented.
44
- change the `pathSelectorType` in the `UtSettings.kt` to the `PathSelectorType.TORCH_SELECTOR`
55
- don't forget the put the Torch model in the path ruled by the setting `modelPath` in the `UtSettings.kt`
66

utbot-analytics-torch/src/main/kotlin/org/utbot/AnalyticsTorchConfiguration.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package org.utbot
33
import org.utbot.analytics.EngineAnalyticsContext
44
import org.utbot.features.FeatureExtractorFactoryImpl
55
import org.utbot.features.FeatureProcessorWithStatesRepetitionFactory
6-
import org.utbot.predictors.StateRewardPredictorWithTorchModelsSupportFactoryImpl
6+
import org.utbot.predictors.TorchPredictorFactoryImpl
77

88
/**
99
* The basic configuration of the utbot-analytics-torch module used in utbot-intellij and (as planned) in utbot-cli
@@ -16,6 +16,6 @@ object AnalyticsTorchConfiguration {
1616
init {
1717
EngineAnalyticsContext.featureProcessorFactory = FeatureProcessorWithStatesRepetitionFactory()
1818
EngineAnalyticsContext.featureExtractorFactory = FeatureExtractorFactoryImpl()
19-
EngineAnalyticsContext.stateRewardPredictorFactory = StateRewardPredictorWithTorchModelsSupportFactoryImpl()
19+
EngineAnalyticsContext.mlPredictorFactory = TorchPredictorFactoryImpl()
2020
}
2121
}

utbot-analytics-torch/src/main/kotlin/org/utbot/predictors/StateRewardPredictorFactory.kt

Lines changed: 0 additions & 11 deletions
This file was deleted.

utbot-analytics-torch/src/main/kotlin/org/utbot/predictors/StateRewardPredictorTorch.kt renamed to utbot-analytics-torch/src/main/kotlin/org/utbot/predictors/TorchPredictor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import ai.djl.ndarray.NDArray
66
import ai.djl.ndarray.NDList
77
import ai.djl.translate.Translator
88
import ai.djl.translate.TranslatorContext
9-
import org.utbot.analytics.StateRewardPredictor
9+
import org.utbot.analytics.MLPredictor
1010
import org.utbot.framework.UtSettings
1111
import java.io.Closeable
1212
import java.nio.file.Paths
1313

14-
class StateRewardPredictorTorch : StateRewardPredictor, Closeable {
14+
class TorchPredictor : MLPredictor, Closeable {
1515
val model: Model
1616

1717
init {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.utbot.predictors
2+
3+
import org.utbot.analytics.MLPredictorFactory
4+
import org.utbot.framework.UtSettings
5+
6+
/**
7+
* Creates [StateRewardPredictor], by checking the [UtSettings] configuration.
8+
*/
9+
class TorchPredictorFactoryImpl : MLPredictorFactory {
10+
override operator fun invoke() = TorchPredictor()
11+
}

utbot-analytics-torch/src/test/kotlin/org/utbot/predictors/NNStateRewardPredictorTest.kt renamed to utbot-analytics-torch/src/test/kotlin/org/utbot/predictors/TorchPredictorTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ package org.utbot.predictors
33
import org.junit.jupiter.api.Assertions.assertEquals
44
import org.junit.jupiter.api.Disabled
55
import org.junit.jupiter.api.Test
6-
import org.utbot.analytics.StateRewardPredictor
6+
import org.utbot.analytics.MLPredictor
77
import org.utbot.testcheckers.withModelPath
88
import kotlin.system.measureNanoTime
99

10-
class NNStateRewardPredictorTest {
10+
class TorchPredictorTest {
1111
@Test
1212
@Disabled("Just to see the performance of predictors")
1313
fun simpleTest() {
1414
withModelPath("src/test/resources") {
15-
val pred = StateRewardPredictorTorch()
15+
val pred = TorchPredictor()
1616

1717
val features = listOf(0.0, 0.0)
1818

@@ -25,13 +25,13 @@ class NNStateRewardPredictorTest {
2525
fun performanceTest() {
2626
val features = (1..13).map { 1.0 }.toList()
2727
withModelPath("models") {
28-
val averageTime = calcAverageTimeForModelPredict(::StateRewardPredictorTorch, 100, features)
28+
val averageTime = calcAverageTimeForModelPredict(::TorchPredictor, 100, features)
2929
println(averageTime)
3030
}
3131
}
3232

3333
private fun calcAverageTimeForModelPredict(
34-
model: () -> StateRewardPredictor,
34+
model: () -> MLPredictor,
3535
iterations: Int,
3636
features: List<Double>
3737
): Double {

utbot-analytics/build.gradle

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ evaluationDependsOn(':utbot-framework')
1212
compileTestJava.dependsOn tasks.getByPath(':utbot-framework:testClasses')
1313

1414
dependencies {
15-
api(project(":utbot-api"))
16-
api(project(":utbot-core"))
17-
api(project(":utbot-summary"))
18-
api(project(":utbot-framework-api"))
19-
api(project(":utbot-fuzzers"))
20-
api(project(":utbot-instrumentation"))
21-
api(project(":utbot-framework"))
15+
implementation(project(":utbot-api"))
16+
implementation(project(":utbot-core"))
17+
implementation(project(":utbot-summary"))
18+
implementation(project(":utbot-framework-api"))
19+
implementation(project(":utbot-fuzzers"))
20+
implementation(project(":utbot-instrumentation"))
21+
implementation(project(":utbot-framework"))
2222
testImplementation project(':utbot-sample')
2323
testImplementation group: 'junit', name: 'junit', version: junit4_version
2424

@@ -30,9 +30,8 @@ dependencies {
3030
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlin_logging_version
3131
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
3232

33-
implementation group: 'org.bytedeco', name: 'arpack-ng', version: "3.7.0-1.5.4", classifier: "$classifier"
34-
implementation group: 'org.bytedeco', name: 'openblas', version: "0.3.10-1.5.4", classifier: "$classifier"
35-
implementation group: 'org.bytedeco', name: 'javacpp', version: javacpp_version, classifier: "$classifier"
33+
implementation group: 'org.bytedeco', name: 'arpack-ng', version: arpack_ng_version, classifier: "$classifier"
34+
implementation group: 'org.bytedeco', name: 'openblas', version: openblas_version, classifier: "$classifier"
3635

3736
implementation group: 'tech.tablesaw', name: 'tablesaw-core', version: '0.38.2'
3837
implementation group: 'tech.tablesaw', name: 'tablesaw-jsplot', version: '0.38.2'

utbot-analytics/src/main/kotlin/org/utbot/AnalyticsConfiguration.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package org.utbot
33
import org.utbot.analytics.EngineAnalyticsContext
44
import org.utbot.features.FeatureExtractorFactoryImpl
55
import org.utbot.features.FeatureProcessorWithStatesRepetitionFactory
6-
import org.utbot.predictors.StateRewardPredictorFactoryImpl
6+
import org.utbot.predictors.MLPredictorFactoryImpl
77

88
/**
99
* The basic configuration of the utbot-analytics module used in utbot-intellij and (as planned) in utbot-cli
@@ -16,6 +16,6 @@ object AnalyticsConfiguration {
1616
init {
1717
EngineAnalyticsContext.featureProcessorFactory = FeatureProcessorWithStatesRepetitionFactory()
1818
EngineAnalyticsContext.featureExtractorFactory = FeatureExtractorFactoryImpl()
19-
EngineAnalyticsContext.stateRewardPredictorFactory = StateRewardPredictorFactoryImpl()
19+
EngineAnalyticsContext.mlPredictorFactory = MLPredictorFactoryImpl()
2020
}
2121
}

0 commit comments

Comments
 (0)