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

Dl4j m2.1 #13

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
7 changes: 1 addition & 6 deletions aisp-core/aisp-core-main-cpu/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1
8 changes: 4 additions & 4 deletions aisp-core/aisp-core-main/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<classpathentry kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
Expand All @@ -13,15 +13,15 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<classpathentry kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">

<wb-module deploy-name="aisp-core-main">

<wb-resource deploy-path="/" source-path="/src/main/java"/>

<wb-resource deploy-path="/" source-path="/src/main/resources"/>

</wb-module>

</project-modules>
42 changes: 39 additions & 3 deletions aisp-core/aisp-core-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</parent>

<artifactId>aisp-core-main</artifactId>
<properties>
<graalvm.version>21.3.6</graalvm.version>
</properties>


<build>
Expand Down Expand Up @@ -62,13 +65,13 @@
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-nn</artifactId>
<version>1.0.0-M1.1</version>
<version>1.0.0-M2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>1.0.0-M1.1</version>
<version>1.0.0-M2.1</version>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -140,7 +143,35 @@
<version>2.1</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.tools</groupId>
<artifactId>profiler</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.graalvm.tools</groupId>
<artifactId>chromeinspector</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>


<!--
#################### Testing dependencies ##############
Expand All @@ -152,5 +183,10 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>15.4</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;

import javax.script.Bindings;
import javax.script.ScriptContext;
Expand All @@ -43,7 +44,22 @@ public JScriptEngine(List<String> allowedClasses) {
// if (engine == null && requireSecurity)
// throw new IllegalArgumentException("Could not enable security");
// } else {
engine = new ScriptEngineManager().getEngineByName("nashorn");
System.setProperty("polyglot.engine.WarnInterpreterOnly", "false"); // Turn off graal interpreter warnings below
// [To redirect Truffle log output to a file use one of the following options:
// * '--log.file=<path>' if the option is passed using a guest language launcher.
// * '-Dpolyglot.log.file=<path>' if the option is passed using the host Java launcher.
// * Configure logging using the polyglot embedding API.]
// [engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation.
// The guest application code will therefore be executed in interpreted mode only.
// Execution only in interpreted mode will strongly impact the guest application performance.
// For more information on using GraalVM see https://www.graalvm.org/java/quickstart/.
// To disable this warning the '--engine.WarnInterpreterOnly=false' option or use the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.
ScriptEngineManager sem= new ScriptEngineManager();
// List<ScriptEngineFactory> sef = sem.getEngineFactories();
engine = sem.getEngineByName("JavaScript"); // The graal engine (not graal.js apparently).
Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
bindings.put("polyglot.js.allowHostAccess", true);
bindings.put("polyglot.js.allowHostClassLookup", (Predicate<String>) s -> true);
// }
}

Expand Down Expand Up @@ -121,24 +137,24 @@ private static Object toJava(Object scriptObj) {
if (scriptObj == null)
return null;

if (scriptObj instanceof jdk.nashorn.api.scripting.ScriptObjectMirror) {
jdk.nashorn.api.scripting.ScriptObjectMirror scriptObjectMirror = (jdk.nashorn.api.scripting.ScriptObjectMirror) scriptObj;
if (scriptObjectMirror.isArray()) {
List<Object> list = new ArrayList<Object>();
for (Map.Entry<String, Object> entry : scriptObjectMirror.entrySet()) {
list.add(toJava(entry.getValue()));
}
return list;
} else {
Map<String, Object> map = new HashMap<String,Object>();
for (Map.Entry<String, Object> entry : scriptObjectMirror.entrySet()) {
map.put(entry.getKey(), toJava(entry.getValue()));
}
return map;
}
} else {
// if (scriptObj instanceof jdk.nashorn.api.scripting.ScriptObjectMirror) {
// jdk.nashorn.api.scripting.ScriptObjectMirror scriptObjectMirror = (jdk.nashorn.api.scripting.ScriptObjectMirror) scriptObj;
// if (scriptObjectMirror.isArray()) {
// List<Object> list = new ArrayList<Object>();
// for (Map.Entry<String, Object> entry : scriptObjectMirror.entrySet()) {
// list.add(toJava(entry.getValue()));
// }
// return list;
// } else {
// Map<String, Object> map = new HashMap<String,Object>();
// for (Map.Entry<String, Object> entry : scriptObjectMirror.entrySet()) {
// map.put(entry.getKey(), toJava(entry.getValue()));
// }
// return map;
// }
// } else {
return scriptObj;
}
// }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void testJSYT_KNNMergeLp() throws AISPException {
Map<String,Object> bindings = new HashMap<String,Object>();
bindings.put("distanceMetric", "Lp");
bindings.put("maxListSize", size);
for ( String multiplier : trueFalse) {
for ( float multiplier : multipliers) {
bindings.put("stddevMultiplier", multiplier);
for ( String outliers : trueFalse) {
bindings.put("enableOutliers", outliers);
Expand Down