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

Twister2 Deep Learning (DO NOT MERGE) #952

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
8042263
Merge branch 'master' of https://github.com/DSC-SPIDAL/twister2
pulasthi Dec 30, 2019
7022187
Merge branch 'master' of https://github.com/pulasthi/twister2
pulasthi Jan 3, 2020
b725da5
Merge branch 'master' of https://github.com/pulasthi/twister2
pulasthi Feb 17, 2020
09bab5a
Merge branch 'master' of https://github.com/pulasthi/twister2
pulasthi Feb 17, 2020
9c7947b
Merge branch 'master' of https://github.com/pulasthi/twister2
pulasthi Sep 16, 2020
af9efe4
creating DL branch
pulasthi Oct 3, 2020
8f83911
adding activity
pulasthi Oct 4, 2020
30e1d6e
adding Table
pulasthi Oct 5, 2020
40b73bd
Merge branch 'master' of https://github.com/DSC-SPIDAL/twister2
pulasthi Oct 5, 2020
91f4b33
Merge branch 'master' into twister2DL
pulasthi Oct 5, 2020
410fdcf
adding dense tensor and tensor sample
pulasthi Oct 6, 2020
a0a3196
adding minimatch impl
pulasthi Oct 6, 2020
f1baa8a
adding storage
pulasthi Oct 7, 2020
44e10d6
update
pulasthi Oct 8, 2020
c87fe0e
adding dense tensor implemention
pulasthi Oct 9, 2020
e1bb8a1
addiing tensor math
pulasthi Oct 10, 2020
cadef54
refactor
pulasthi Oct 10, 2020
742b0a5
refactor
pulasthi Oct 10, 2020
e713895
adding source for DL
pulasthi Oct 12, 2020
2aba282
adding MSE and start module section
pulasthi Oct 13, 2020
7f0bde6
adding optimizer adam
pulasthi Oct 14, 2020
0d4fa82
update code
pulasthi Oct 16, 2020
0b48582
adding modules
pulasthi Oct 17, 2020
8740c35
adding modules
pulasthi Oct 17, 2020
3b5491b
adding modules
pulasthi Oct 19, 2020
5814992
adding relu and sigmoid
pulasthi Oct 19, 2020
f4fb1f1
iteration 1 complete refactored
pulasthi Oct 20, 2020
a5574a6
adding minibatch source
pulasthi Oct 21, 2020
fb18fa4
fixing bugs on model.forward
pulasthi Oct 21, 2020
01e0d7e
forward call going through without exception
pulasthi Oct 22, 2020
d3cff3d
forward call going through without exception
pulasthi Oct 22, 2020
b54f174
forward and backward working
pulasthi Oct 23, 2020
172233f
working correct loss calc for seq
pulasthi Oct 23, 2020
293f245
initial parallel working for loss calc
pulasthi Oct 24, 2020
6ac7f9f
grad calculation working on parallel test
pulasthi Oct 25, 2020
f324376
supporting epoch
pulasthi Oct 26, 2020
dccdcba
mini batching working
pulasthi Oct 27, 2020
178015a
adding timmings
pulasthi Oct 27, 2020
9d2f27c
working has memory issue
pulasthi Oct 29, 2020
7b51569
working model
pulasthi Oct 30, 2020
11d92f3
timming correction
pulasthi Oct 31, 2020
30e133c
pass in file
pulasthi Nov 1, 2020
5a32ccf
Adding large AE
pulasthi Nov 1, 2020
290f7f1
fix ram input
pulasthi Nov 1, 2020
0661b27
Adding timmings
pulasthi Nov 2, 2020
827ea30
Adding timmings
pulasthi Nov 2, 2020
17f2b41
Adding custom data packer
pulasthi Nov 4, 2020
e1cd9c4
adding custom packer
pulasthi Nov 4, 2020
41a68e2
Adding timming
pulasthi Nov 5, 2020
1e4f248
adding timmings
pulasthi Nov 5, 2020
10dfa0d
adding timmings
pulasthi Nov 8, 2020
194c37b
adding timmings
pulasthi Nov 8, 2020
c42b915
adding timmings
pulasthi Nov 9, 2020
225841a
fixing issue with datapacker
pulasthi Nov 9, 2020
c7f6cb7
adding conv layers
pulasthi Dec 2, 2020
d75e728
adding more modules
pulasthi Dec 8, 2020
84cc6a6
adding cnn layer modules
pulasthi Dec 13, 2020
5387d9d
updating fixes
pulasthi Dec 15, 2020
fcbf71a
update
pulasthi Dec 16, 2020
5d6de8d
working Mnist Example
pulasthi Dec 22, 2020
c635561
commit before mkl DNN changes
pulasthi Jan 25, 2021
8d83f06
Adding initial mkl dnn code
pulasthi Jan 29, 2021
b44f775
adding float changes
pulasthi Jan 31, 2021
fd6292f
adding float changes
pulasthi Feb 1, 2021
c188005
adding float changes
pulasthi Feb 1, 2021
a2d43b4
working float example
pulasthi Feb 5, 2021
b07ed80
adding mkl-dnn support
pulasthi Feb 6, 2021
ac08050
update dnn
pulasthi Feb 7, 2021
6767fb8
adding dnn changes
pulasthi Feb 14, 2021
b18b6b1
adding dnn changes
pulasthi Feb 14, 2021
f6558e7
push local changes
pulasthi Feb 23, 2021
4dd0a85
update dnn code
pulasthi Feb 24, 2021
1b8615f
updating code
pulasthi Mar 8, 2021
bb7ded3
fixing issues
pulasthi Mar 11, 2021
74534a9
small changes
pulasthi Mar 14, 2021
b99e2c8
small changes
pulasthi Mar 15, 2021
72f82d5
data gen
pulasthi Mar 28, 2021
3cc577b
adding changes
pulasthi Mar 28, 2021
d7b188c
remove logs
pulasthi Mar 28, 2021
624efb8
adding custom net
pulasthi Mar 28, 2021
f4e9bcb
adding custom net
pulasthi Mar 28, 2021
a340f86
adding custom net
pulasthi Mar 28, 2021
d113dc8
updating
pulasthi Apr 3, 2021
a20ff24
CNN
pulasthi Apr 18, 2021
6837811
cnn update
pulasthi Apr 21, 2021
b7177c7
CNN datagen
pulasthi Apr 24, 2021
64b4883
updates
pulasthi Apr 25, 2021
e7a598b
mdscl
pulasthi May 16, 2021
8024232
Merge branch 'master' into twister2DL
supunkamburugamuve Jul 29, 2021
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
12 changes: 12 additions & 0 deletions scripts/package/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ load("//tools/rules:twister2_core.bzl", "twister2_storm_files")
load("//tools/rules:twister2_core.bzl", "twister2_beam_files")
load("//tools/rules:twister2_core.bzl", "twister2_core_checkpointing_files")
load("//tools/rules:twister2_core.bzl", "twister2_core_tset_files")
load("//tools/rules:twister2_core.bzl", "twister2_core_dl_files")
load("//tools/rules:twister2_core.bzl", "twister2_python_support_files")
load("//tools/rules:twister2_master.bzl", "twister2_master_lib_files")
load("//tools/rules:twister2_master.bzl", "twister2_master_jersey_files")
Expand Down Expand Up @@ -106,6 +107,7 @@ pack_tw2(
":twister2-master-lib",
":twister2-python-support",
":twister2-tset",
":twister2-dl",
],
)

Expand Down Expand Up @@ -142,6 +144,7 @@ pack_tw2(
":twister2-ompi-lib",
":twister2-python-support",
":twister2-tset",
":twister2-dl",
],
)

Expand Down Expand Up @@ -339,6 +342,7 @@ pack_tw2(
":twister2-python-examples",
":twister2-python-support",
":twister2-tset",
":twister2-dl",
":twister2-ucx-native-libs",
":twister2-ucx-native-libs-dir"
],
Expand Down Expand Up @@ -402,6 +406,7 @@ pack_tw2(
":twister2-test-util",
":twister2-test-values",
":twister2-tset",
":twister2-dl",
":twister2-ucx-native-libs",
":twister2-ucx-native-libs-dir"
],
Expand Down Expand Up @@ -638,6 +643,13 @@ pack_tw2(
version = T2_VERSION,
)

pack_tw2(
name = "twister2-dl",
srcs = twister2_core_dl_files(),
package_dir = "lib",
version = T2_VERSION,
)

pack_tw2(
name = "twister2-test",
srcs = ["//util/test"],
Expand Down
22 changes: 22 additions & 0 deletions t2_workspace_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def load_modules():
"io.netty:netty-all:4.1.27.Final",
"io.netty:netty-transport:4.1.27.Final",
"io.netty:netty-transport-native-epoll:4.1.27.Final",
"org.apache.commons:commons-math3:3.6.1",
],
repositories = [
"https://repo1.maven.org/maven2",
Expand Down Expand Up @@ -327,3 +328,24 @@ def load_modules():
_maven_import(artifact = "org.easymock:easymock:4.0.2", licenses = ["notice"], sha256 = "104370107ef64d115e642cbdc14cea438a8d076f5aee9a9cb7882dc9a8ed4123")
_maven_import(artifact = "org.apache.commons:commons-collections4:4.4", licenses = ["notice"], sha256 = "1df8b9430b5c8ed143d7815e403e33ef5371b2400aadbe9bda0883762e0846d1")
_maven_import(artifact = "org.apache.commons:commons-configuration2:2.6", licenses = ["notice"], sha256 = "225788911e53af0b29a31a18e0d03b05d86aa9c9e0b3c6686982c30c10f931fb")


#for DL
_maven_import(artifact = "org.apache.maven:maven-plugin-api:2.0",licenses = ["notice"],sha256 = "5b62626069d85bb463314572734988d47bc98aab9f0ed48d2f1f9554960f5a35",)
_maven_import(artifact = "org.qunix:structure-maven-plugin:0.0.2",licenses = ["notice"],sha256 = "5f07ad70ba250c2fd49937ea6cbc1cbb51d8facd43872fbf65dff47e6d8858fc",)
_maven_import(artifact = "org.apache.maven:maven-profile:2.0.8",licenses = ["notice"],sha256 = "bd566c2fdb896e3dd157dc3e49b3c10f93250daaa6462af3cd42ad5b4aeda0a3",)
_maven_import(artifact = "org.hamcrest:hamcrest-core:1.3",licenses = ["notice"],sha256 = "66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9",)
_maven_import(artifact = "org.apache.maven:maven-plugin-registry:2.0.8",licenses = ["notice"],sha256 = "a7e77626ec4c8382a4c11ba808684402582693df00f0c39f7c0fc02cd1ece9ab",)
_maven_import(artifact = "org.apache.maven:maven-repository-metadata:2.0.8",licenses = ["notice"],sha256 = "aff8473e802e4e1c226a777a198f72fbdf7ef36f6f972df6de763b767f652ee1",)
_maven_import(artifact = "org.apache.maven:maven-settings:2.0.8",licenses = ["notice"],sha256 = "e1873a36ea2debc0bb6210c3064faae91cf12108e9f8b9845e283022f58ecb46",)
_maven_import(artifact = "classworlds:classworlds:1.1",licenses = ["notice"],sha256 = "4e3e0ad158ec60917e0de544c550f31cd65d5a97c3af1c1968bf427e4a9df2e4",)
_maven_import(artifact = "org.apache.maven.wagon:wagon-provider-api:1.0",licenses = ["notice"],sha256 = "b28dd1302ac34433d8d1b45fb254e093cd7b47277441af2018c8a3a4d8c1a60d",)
_maven_import(artifact = "org.apache.maven:maven-artifact-manager:2.0.8",licenses = ["notice"],sha256 = "c257564b252dc69ff3f3603971164fcb387adbd000818e72c959e6be7b6319cd",)
_maven_import(artifact = "org.apache.maven:maven-artifact:2.0.8",licenses = ["notice"],sha256 = "5cf23417cdee6a8e1eb6b9c015c8feea62cedb7dceb3ad098e6869569fcfd1c0",)
_maven_import(artifact = "org.apache.maven:maven-model:2.0.8",licenses = ["notice"],sha256 = "51cde4f45d74720eaf567444d88c9ffdfc6896dd58dcc459403f6613d8439255",)
_maven_import(artifact = "org.apache.maven:maven-project:2.0.8",licenses = ["notice"],sha256 = "46799ed8812c96f1e651958cbd864155cc8a9ae8d4ebe2392b845d232a910d31",)
_maven_import(artifact = "junit:junit:4.11",licenses = ["notice"],sha256 = "90a8e1603eeca48e7e879f3afbc9560715322985f39a274f6f6070b43f9d06fe",)
_maven_import(artifact = "org.codehaus.plexus:plexus-utils:1.4.6",licenses = ["notice"],sha256 = "b46fe183dc28526d083287817e6374ad460cef2d780f6096d3ea46caa0a25106",)
_maven_import(artifact = "org.apache.commons:commons-lang3:3.3.2",licenses = ["notice"],sha256 = "6b81d10754dadf184d386011486e6509c2cc0c3d33565ced4fb4402b9413d47d",)
_maven_import(artifact = "commons-collections:commons-collections:3.2.1",licenses = ["notice"],sha256 = "87363a4c94eaabeefd8b930cb059f66b64c9f7d632862f23de3012da7660047b",)
_maven_import(artifact = "com.intel.analytics.bigdl.core.dist:all:0.11.1",licenses = ["notice"],sha256 = "6d5ff2212f362d289cbb3db0b401fe5ad5005a63aafce251252130ce0d0c6a7a",)
6 changes: 6 additions & 0 deletions tools/rules/twister2_core.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ def twister2_core_tset_files():
"@maven//:com_google_re2j_re2j"
]

def twister2_core_dl_files():
return [
"//twister2/dl/src/java:twister2dl-java",
"@com_intel_analytics_bigdl_core_dist_all//jar",
]

def twister2_storm_files():
return [
"//twister2/compatibility/storm:twister2-storm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void open(Config cfg) throws IOException {
@Override
public String nextRecord(Object record) throws IOException {
if (readLine()) {
return readRecord(this.readBuffer, this.currOffset, this.currLen);
return readRecord(this.currBuffer, this.currOffset, this.currLen);
} else {
this.end = true;
return null;
Expand Down Expand Up @@ -245,7 +245,7 @@ protected final boolean readLine() throws IOException {
}
readPos++;
}
if (readPos == limit) {
if (readPos == limit && this.splitLength == 0) {
this.end = true;
}
if (delimPos == this.delimiter.length) {
Expand Down
41 changes: 41 additions & 0 deletions twister2/dl/src/java/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package(default_visibility = ["//visibility:public"])

load("//tools:maven.bzl", "t2_java_lib")

t2_java_lib(
name = "twister2dl-java",
srcs = glob(["**/*.java"]),
artifact_name = "Twiter2 TSet Implementation",
deps = [
"//twister2/api/src/java/edu/iu/dsc/tws/api/checkpointing:checkpointing-api-java",
"//twister2/api/src/java/edu/iu/dsc/tws/api/comms:comms-api-java",
"//twister2/api/src/java/edu/iu/dsc/tws/api/compute:task-api-java",
"//twister2/api/src/java/edu/iu/dsc/tws/api/config:config-api-java",
"//twister2/api/src/java/edu/iu/dsc/tws/api/data:data-api-java",
"//twister2/api/src/java/edu/iu/dsc/tws/api/dataset:dataset-api-java",
"//twister2/api/src/java/edu/iu/dsc/tws/api/faulttolerance:fault-tolerance-api-java",
"//twister2/api/src/java/edu/iu/dsc/tws/api/resource:resource-api-java",
"//twister2/api/src/java/edu/iu/dsc/tws/api/tset:tset-api-java",
"//twister2/api/src/java/edu/iu/dsc/tws/api/exceptions:exceptions-java",
"//twister2/checkpointing/src/java:checkpointing-java",
"//twister2/common/src/java:common-java",
"//twister2/data/src/main/java:data-java",
"//twister2/task/src/main/java:task-java",
"//twister2/proto:proto-java",
"//twister2/proto/utils:proto-utils-java",
"//twister2/master/src/java:master-java",
"//twister2/tset/src/java:tset-java",
"@com_google_protobuf//:protobuf_java",
"@com_google_guava_guava",
"@org_apache_hadoop_hadoop_common//jar",
"@org_apache_hadoop_hadoop_mapreduce_client_core//jar",
"@com_intel_analytics_bigdl_core_dist_all//jar",
"@maven//:org_apache_commons_commons_math3",
"@maven//:com_google_flatbuffers_flatbuffers_java",
"@maven//:javax_annotation_javax_annotation_api",
"@maven//:io_netty_netty_buffer",
"@maven//:io_netty_netty_all",
"@maven//:io_netty_netty_transport",
"@maven//:io_netty_netty_transport_native_epoll",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package edu.iu.dsc.tws.dl.criterion;

import edu.iu.dsc.tws.dl.data.Activity;
import edu.iu.dsc.tws.dl.data.tensor.DenseTensor;

/**
* [[AbstractCriterion]] is an abstract class the concrete criterion should extend.
* `Criterion`s are helpful to train a neural network. Given an input and a target,
* they compute the gradient according to a loss function.
* <p>
* It provides some important method such as `forward`, `backward`, `updateOutput`,
* `updateGradInput` frequently used as a criteria. Some of them need to be override
* in a concrete criterion class.
*
* @tparam A represents the input type of the criterion, which an be abstract type [[Activity]],
* or concrete type [[Tensor]] or [[Table]]
* @tparam B represents the output type of the criterion
*/
public abstract class AbstractCriterion<I extends Activity, O extends Activity>
implements Criterion {
protected I gradInput;
protected double output;
protected float outputf;
protected boolean isFloat;
protected SizeAverageStatus sizeAverageStatus = SizeAverageStatus.NONE;

public AbstractCriterion() {
gradInput = (I) new DenseTensor(false);
output = 0.0;
outputf = 0.0f;
isFloat = false;
}

public void toFloat() {
isFloat = true;
gradInput = (I) new DenseTensor(true);
}

public Activity getGradInput() {
return gradInput;
}

public void setGradInput(I gradInput) {
this.gradInput = gradInput;
}

public double getOutput() {
return output;
}

public float getOutputf() {
return outputf;
}

public void setOutput(double output) {
this.output = output;
}

public void setOutput(float output) {
this.outputf = output;
}

/**
* Takes an input object, and computes the corresponding loss of the criterion,
* compared with `target`.
*
* @param input input data
* @param target target
* @return the loss of criterion
*/
public double forward(I input, O target) {
return updateOutput(input, target);
}

public float forwardf(I input, O target) {
return updateOutputf(input, target);
}

/**
* Performs a back-propagation step through the criterion, with respect to the given input.
*
* @param input input data
* @param target target
* @return gradient corresponding to input data
*/
public I backward(I input, O target) {
return updateGradInput(input, target);
}

/**
* Computes the loss using input and objective function. This function
* returns the result which is stored in the output field.
*
* @param input input of the criterion
* @param target target or labels
* @return the loss of the criterion
*/
public double updateOutput(I input, O target) {
return this.output;
}

public float updateOutputf(I input, O target) {
return this.outputf;
}

/**
* Computing the gradient of the criterion with respect to its own input. This is returned in
* gradInput. Also, the gradInput state variable is updated accordingly.
*
* @param input input data
* @param target target data / labels
* @return gradient of input
*/
public abstract I updateGradInput(I input, O target);

/**
* Deep copy this criterion
*
* @return a deep copied criterion
*/
AbstractCriterion<I, O> cloneCriterion() {
throw new UnsupportedOperationException("Clone not supported");
}

@Override
public int hashCode() {
//TODO check correctness
if (this.isFloat) {
return Double.valueOf(outputf).hashCode();
} else {
return Double.valueOf(output).hashCode();
}
}

public boolean canEqual(Object other) {
return other instanceof AbstractCriterion;
}

@Override
public boolean equals(Object other) {
if (this.isFloat) {
return other instanceof AbstractCriterion && other.getClass() == this.getClass()
&& this.outputf == ((AbstractCriterion<?, ?>) other).getOutput();
} else {
return other instanceof AbstractCriterion && other.getClass() == this.getClass()
&& this.output == ((AbstractCriterion<?, ?>) other).getOutput();
}
}

enum SizeAverageStatus {
TRUE,
FALSE,
NONE
}
}
Loading