Skip to content

Commit

Permalink
JNN 6.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Jet132 committed Aug 10, 2018
1 parent a783cc9 commit 5f24c83
Show file tree
Hide file tree
Showing 49 changed files with 1,172 additions and 31 deletions.
Binary file removed AI Engine 6.3.7.jar
Binary file not shown.
Binary file removed AI_Engine_6.3.7 Example/AI Engine 6.3.7.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@
<classpathentry kind="lib" path="commons-math3-3.6.1/commons-math3-3.6.1-tests.jar"/>
<classpathentry kind="lib" path="commons-math3-3.6.1/commons-math3-3.6.1-tools.jar"/>
<classpathentry kind="lib" path="commons-math3-3.6.1/commons-math3-3.6.1.jar"/>
<classpathentry kind="lib" path="AI Engine 6.3.7.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 1 addition & 1 deletion AI_Engine_6.3.7 Example/.project → JNN 6.3.8/.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AI_Engine_6.3.7 Example</name>
<name>JNN 6.3.8</name>
<comment></comment>
<projects>
</projects>
Expand Down
251 changes: 251 additions & 0 deletions JNN 6.3.8/LayerKernel.ptx
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
//
// Generated by NVIDIA NVVM Compiler
//
// Compiler Build ID: CL-22781540
// Cuda compilation tools, release 9.0, V9.0.176
// Based on LLVM 3.4svn
//

.version 6.0
.target sm_30
.address_size 64

// .globl layer

.visible .entry layer(
.param .u32 layer_param_0,
.param .u32 layer_param_1,
.param .u64 layer_param_2,
.param .u64 layer_param_3,
.param .u64 layer_param_4,
.param .u64 layer_param_5
)
{
.reg .pred %p<18>;
.reg .f32 %f<116>;
.reg .b32 %r<37>;
.reg .f64 %fd<5>;
.reg .b64 %rd<35>;


ld.param.u32 %r17, [layer_param_0];
ld.param.u32 %r18, [layer_param_1];
ld.param.u64 %rd11, [layer_param_2];
ld.param.u64 %rd8, [layer_param_3];
ld.param.u64 %rd9, [layer_param_4];
ld.param.u64 %rd10, [layer_param_5];
cvta.to.global.u64 %rd1, %rd8;
cvta.to.global.u64 %rd2, %rd11;
mov.u32 %r1, %ntid.x;
mov.u32 %r2, %ctaid.x;
mov.u32 %r3, %tid.x;
mad.lo.s32 %r4, %r1, %r2, %r3;
setp.gt.s32 %p1, %r4, %r18;
@%p1 bra BB0_19;

mov.f32 %f19, 0f00000000;
setp.lt.s32 %p2, %r17, 1;
mov.f32 %f113, %f19;
@%p2 bra BB0_11;

and.b32 %r22, %r17, 3;
mov.f32 %f113, 0f00000000;
mov.u32 %r34, 0;
setp.eq.s32 %p3, %r22, 0;
@%p3 bra BB0_8;

setp.eq.s32 %p4, %r22, 1;
@%p4 bra BB0_7;

setp.eq.s32 %p5, %r22, 2;
@%p5 bra BB0_6;

ld.global.f32 %f23, [%rd2];
mul.wide.s32 %rd12, %r4, 4;
add.s64 %rd13, %rd1, %rd12;
ld.global.f32 %f24, [%rd13];
fma.rn.f32 %f113, %f23, %f24, 0f00000000;
mov.u32 %r34, 1;

BB0_6:
mul.wide.u32 %rd14, %r34, 4;
add.s64 %rd15, %rd2, %rd14;
neg.s32 %r24, %r34;
and.b32 %r25, %r24, %r18;
add.s32 %r26, %r25, %r4;
mul.wide.s32 %rd16, %r26, 4;
add.s64 %rd17, %rd1, %rd16;
ld.global.f32 %f25, [%rd17];
ld.global.f32 %f26, [%rd15];
fma.rn.f32 %f113, %f26, %f25, %f113;
add.s32 %r34, %r34, 1;

BB0_7:
mul.wide.s32 %rd18, %r34, 4;
add.s64 %rd19, %rd2, %rd18;
mad.lo.s32 %r27, %r34, %r18, %r4;
mul.wide.s32 %rd20, %r27, 4;
add.s64 %rd21, %rd1, %rd20;
ld.global.f32 %f27, [%rd21];
ld.global.f32 %f28, [%rd19];
fma.rn.f32 %f113, %f28, %f27, %f113;
add.s32 %r34, %r34, 1;

BB0_8:
setp.lt.u32 %p6, %r17, 4;
@%p6 bra BB0_11;

shl.b32 %r10, %r18, 2;
mul.wide.s32 %rd22, %r34, 4;
add.s64 %rd34, %rd2, %rd22;
mad.lo.s32 %r35, %r34, %r18, %r4;

BB0_10:
mul.wide.s32 %rd23, %r35, 4;
add.s64 %rd24, %rd1, %rd23;
ld.global.f32 %f29, [%rd24];
ld.global.f32 %f30, [%rd34];
fma.rn.f32 %f31, %f30, %f29, %f113;
cvt.s64.s32 %rd25, %r10;
add.s64 %rd26, %rd24, %rd25;
ld.global.f32 %f32, [%rd26];
ld.global.f32 %f33, [%rd34+4];
fma.rn.f32 %f34, %f33, %f32, %f31;
add.s64 %rd27, %rd26, %rd25;
ld.global.f32 %f35, [%rd27];
ld.global.f32 %f36, [%rd34+8];
fma.rn.f32 %f37, %f36, %f35, %f34;
add.s64 %rd28, %rd27, %rd25;
ld.global.f32 %f38, [%rd28];
ld.global.f32 %f39, [%rd34+12];
fma.rn.f32 %f113, %f39, %f38, %f37;
add.s64 %rd34, %rd34, 16;
add.s32 %r35, %r35, %r10;
add.s32 %r34, %r34, 4;
setp.lt.s32 %p7, %r34, %r17;
@%p7 bra BB0_10;

BB0_11:
cvta.to.global.u64 %rd7, %rd10;
cvta.to.global.u64 %rd29, %rd9;
mul.wide.s32 %rd30, %r4, 4;
add.s64 %rd31, %rd29, %rd30;
ld.global.f32 %f42, [%rd31];
add.f32 %f10, %f113, %f42;
neg.f32 %f43, %f10;
mov.f32 %f41, 0f4016FC2A;
// inline asm
rcp.approx.ftz.f32 %f40,%f41;
// inline asm
mul.f32 %f44, %f40, 0f3F37E150;
mul.f32 %f45, %f44, %f44;
mov.f32 %f46, 0f3C4CAF63;
mov.f32 %f47, 0f3B18F0FE;
fma.rn.f32 %f48, %f47, %f45, %f46;
mov.f32 %f49, 0f3DAAAABD;
fma.rn.f32 %f50, %f48, %f45, %f49;
mul.rn.f32 %f51, %f50, %f45;
mul.rn.f32 %f52, %f51, %f44;
mov.f32 %f53, 0f3EB7E150;
sub.f32 %f54, %f53, %f44;
mul.f32 %f55, %f40, 0fBF37E150;
add.f32 %f56, %f54, %f54;
fma.rn.f32 %f57, %f55, %f53, %f56;
mul.rn.f32 %f58, %f40, %f57;
add.f32 %f59, %f44, %f52;
sub.f32 %f60, %f44, %f59;
add.f32 %f61, %f52, %f60;
add.f32 %f62, %f58, %f61;
add.f32 %f63, %f59, %f62;
sub.f32 %f64, %f59, %f63;
add.f32 %f65, %f62, %f64;
mov.f32 %f66, 0f3F317200;
mov.f32 %f67, 0f3F800000;
mul.rn.f32 %f68, %f67, %f66;
add.f32 %f69, %f68, %f63;
sub.f32 %f70, %f68, %f69;
add.f32 %f71, %f63, %f70;
add.f32 %f72, %f65, %f71;
mov.f32 %f73, 0f35BFBE8E;
mul.rn.f32 %f74, %f67, %f73;
add.f32 %f75, %f74, %f72;
add.f32 %f76, %f69, %f75;
sub.f32 %f77, %f69, %f76;
add.f32 %f78, %f75, %f77;
abs.f32 %f11, %f43;
setp.gt.f32 %p8, %f11, 0f77F684DF;
mul.f32 %f79, %f10, 0fB9000000;
selp.f32 %f80, %f79, %f43, %p8;
mul.rn.f32 %f81, %f80, %f76;
neg.f32 %f82, %f81;
fma.rn.f32 %f83, %f80, %f76, %f82;
fma.rn.f32 %f84, %f80, %f78, %f83;
fma.rn.f32 %f86, %f19, %f76, %f84;
add.rn.f32 %f87, %f81, %f86;
neg.f32 %f88, %f87;
add.rn.f32 %f89, %f81, %f88;
add.rn.f32 %f90, %f89, %f86;
mov.b32 %r29, %f87;
setp.eq.s32 %p9, %r29, 1118925336;
add.s32 %r30, %r29, -1;
mov.b32 %f91, %r30;
add.f32 %f92, %f90, 0f37000000;
selp.f32 %f93, %f91, %f87, %p9;
selp.f32 %f12, %f92, %f90, %p9;
mul.f32 %f94, %f93, 0f3FB8AA3B;
cvt.rzi.f32.f32 %f95, %f94;
mov.f32 %f96, 0fBF317200;
fma.rn.f32 %f97, %f95, %f96, %f93;
mov.f32 %f98, 0fB5BFBE8E;
fma.rn.f32 %f99, %f95, %f98, %f97;
mul.f32 %f100, %f99, 0f3FB8AA3B;
ex2.approx.ftz.f32 %f101, %f100;
add.f32 %f102, %f95, 0f00000000;
ex2.approx.f32 %f103, %f102;
mul.f32 %f104, %f101, %f103;
setp.lt.f32 %p10, %f93, 0fC2D20000;
selp.f32 %f105, 0f00000000, %f104, %p10;
setp.gt.f32 %p11, %f93, 0f42D20000;
selp.f32 %f115, 0f7F800000, %f105, %p11;
setp.eq.f32 %p12, %f115, 0f7F800000;
@%p12 bra BB0_13;

fma.rn.f32 %f115, %f115, %f12, %f115;

BB0_13:
add.f32 %f106, %f11, 0f402DF854;
mov.b32 %r31, %f106;
setp.lt.s32 %p13, %r31, 2139095040;
@%p13 bra BB0_18;

setp.gtu.f32 %p14, %f11, 0f7F800000;
@%p14 bra BB0_17;
bra.uni BB0_15;

BB0_17:
mov.f32 %f107, 0f402DF854;
sub.f32 %f115, %f107, %f10;
bra.uni BB0_18;

BB0_15:
setp.neu.f32 %p15, %f11, 0f7F800000;
@%p15 bra BB0_18;

setp.gt.f32 %p16, %f10, 0f80000000;
selp.f32 %f115, 0f00000000, 0f7F800000, %p16;

BB0_18:
cvt.f64.f32 %fd1, %f115;
add.f64 %fd2, %fd1, 0d3FF0000000000000;
rcp.rn.f64 %fd3, %fd2;
setp.eq.f32 %p17, %f10, 0f80000000;
selp.f64 %fd4, 0d3FE0000000000000, %fd3, %p17;
cvt.rn.f32.f64 %f108, %fd4;
add.s64 %rd33, %rd7, %rd30;
st.global.f32 [%rd33], %f108;

BB0_19:
ret;
}


Binary file added JNN 6.3.8/bin/CPUClasses/CPUAgent$1.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/CPUClasses/CPUAgent.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/CPUClasses/CPUDataManager.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/CPUClasses/CPUEvolver.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/CPUClasses/child.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/GPUClasses/GPUAgent$1.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/GPUClasses/GPUAgent.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/GPUClasses/GPUDataManager.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/GPUClasses/GPUEvolver.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/GPUClasses/child.class
Binary file not shown.
Binary file added JNN 6.3.8/bin/JNN/JNN.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
124 changes: 124 additions & 0 deletions JNN 6.3.8/src/CPUClasses/CPUAgent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package CPUClasses;

import java.util.Random;

import org.apache.commons.math3.linear.MatrixUtils;
import org.apache.commons.math3.linear.RealMatrix;

import JNN.JNN;

public class CPUAgent {

private RealMatrix Inputs;
private RealMatrix[] baises;
private RealMatrix[] weights;
private RealMatrix Outputs;
private float points[];
private Thread thread;
private Runnable runNN;

private double sigmoid(double x) {
return (1 / (1 + Math.pow(Math.E, -x)));
}

public CPUAgent(int Generationsteps, int[] layout) {
points = new float[Generationsteps];
this.Inputs = MatrixUtils.createRealMatrix(1, layout[0]);
baises = new RealMatrix[layout.length - 1];
weights = new RealMatrix[layout.length - 1];
int last_layer = layout[0];
Random random = new Random();
for (int i = 0; i < weights.length; i++) {
baises[i] = MatrixUtils.createRealMatrix(1, layout[i + 1]);
weights[i] = MatrixUtils.createRealMatrix(last_layer, layout[i + 1]);

for (int j = 0; j < layout[i + 1]; j++) {
baises[i].setEntry(0, j, random.nextDouble() * 2 - 1);
for (int k = 0; k < last_layer; k++) {
weights[i].setEntry(k, j, random.nextDouble() * 2 - 1);
}
}
last_layer = layout[i + 1];

}
runNN = new Runnable() {

@Override
public void run() {
RealMatrix last_layer = Inputs;
for (int i = 0; i < weights.length; i++) {
last_layer = last_layer.multiply(weights[i]);
last_layer = last_layer.add(baises[i]);
for (int j = 0; j < last_layer.getColumnDimension(); j++) {
last_layer.setEntry(0, j, sigmoid(last_layer.getEntry(0, j)));
}
}
Outputs = last_layer;

}
};
}

public void setInput(int Input, double Value) {
Inputs.setEntry(0, Input, Value);
}

public void runNN() {
RealMatrix last_layer = Inputs;
for (int i = 0; i < weights.length; i++) {
last_layer = last_layer.multiply(weights[i]);
last_layer = last_layer.add(baises[i]);
for (int j = 0; j < last_layer.getColumnDimension(); j++) {
last_layer.setEntry(0, j, sigmoid(last_layer.getEntry(0, j)));
}
}
Outputs = last_layer;
}

public void runNNMT() {
thread = new Thread(runNN);
thread.start();
}

public void joinThread() {
try {
thread.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public double getOutput(int Output) {
return Outputs.getEntry(0, Output);
}

public void setScore(float Score) {
points[JNN.generationStep] = Score;
}

float getAvarageScore() {
float temp = 0;
for (int i = 0; i < points.length; i++) {
temp += points[i];
}
return temp / points.length;
}

RealMatrix[] getWeights() {
return weights;
}

RealMatrix[] getBaises() {
return baises;
}

void setWeights(RealMatrix[] weights) {
this.weights = weights;
}

void setBaises(RealMatrix[] baises) {
this.baises = baises;
}

}
Loading

0 comments on commit 5f24c83

Please sign in to comment.