Skip to content

Commit

Permalink
Merge branch 'intel:master' into parallel-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
olegkkruglov authored Aug 2, 2023
2 parents 9ae5e76 + 6ec8f38 commit 7406562
Show file tree
Hide file tree
Showing 120 changed files with 1,866 additions and 1,328 deletions.
2 changes: 1 addition & 1 deletion .ci/pipeline/build-and-test-lnx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ steps:
displayName: 'System info'
- script: |
conda update -y -q conda
if [ $(echo $(PYTHON_VERSION) | grep '3.7') ] || [ $(echo $(PYTHON_VERSION) | grep '3.11') ]; then export DPCPP_PACKAGE="dpcpp-cpp-rt>=2023.1.0"; else export DPCPP_PACKAGE="dpctl>=0.14 dpcpp-cpp-rt>=2023.1.0"; fi
if [ $(echo $(PYTHON_VERSION) | grep '3.7') ] || [ $(echo $(PYTHON_VERSION) | grep '3.11') ]; then export DPCPP_PACKAGE="dpcpp-cpp-rt>=2023.2.0"; else export DPCPP_PACKAGE="dpctl>=0.14 dpcpp-cpp-rt>=2023.2.0"; fi
conda create -q -y -n CB -c conda-forge -c intel python=$(PYTHON_VERSION) dal-devel mpich pyyaml $DPCPP_PACKAGE
displayName: 'Conda create'
- script: |
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/install_dpcpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo add-apt-repository -y "deb https://apt.repos.intel.com/oneapi all main"
sudo apt-get update
sudo apt-get install -y intel-dpcpp-cpp-compiler-2023.1.0
sudo apt-get install -y intel-dpcpp-cpp-compiler-2023.2.0
sudo bash -c 'echo libintelocl.so > /etc/OpenCL/vendors/intel-cpu.icd'
sudo mv -f /opt/intel/oneapi/compiler/latest/linux/lib/oclfpga /opt/intel/oneapi/compiler/latest/linux/lib/oclfpga_
20 changes: 11 additions & 9 deletions examples/daal4py/adaboost_batch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#===============================================================================
# ===============================================================================
# Copyright 2014 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,26 +12,28 @@
# 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.
#===============================================================================
# ===============================================================================

# daal4py Adaboost example for shared memory systems

import daal4py as d4p
import numpy as np

import daal4py as d4p

# let's try to use pandas' fast csv reader
try:
import pandas

def read_csv(f, c, t=np.float64):
return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t)
return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t)

except ImportError:
# fall back to numpy loadtxt
def read_csv(f, c, t=np.float64):
return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2)
return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2)


def main(readcsv=read_csv, method='defaultDense'):
def main(readcsv=read_csv, method="defaultDense"):
infile = "./data/batch/adaboost_train.csv"
testfile = "./data/batch/adaboost_test.csv"
nClasses = 2
Expand All @@ -55,7 +57,7 @@ def main(readcsv=read_csv, method='defaultDense'):

# The prediction result provides prediction
assert predict_result.prediction.shape == (pdata.shape[0], dep_data.shape[1])
ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=',', ndmin=2)
ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=",", ndmin=2)
assert np.allclose(predict_result.prediction, ptdata)

return (train_result, predict_result, ptdata)
Expand All @@ -66,6 +68,6 @@ def main(readcsv=read_csv, method='defaultDense'):
print("\nGround truth (first 20 observations):\n", ptdata[:20])
print(
"Adaboost classification results: (first 20 observations):\n",
predict_result.prediction[:20]
predict_result.prediction[:20],
)
print('All looks good!')
print("All looks good!")
28 changes: 16 additions & 12 deletions examples/daal4py/adagrad_mse_batch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#===============================================================================
# ===============================================================================
# Copyright 2014 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,27 +12,29 @@
# 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.
#===============================================================================
# ===============================================================================

# daal4py AdaGrad (Adaptive Subgradient Method) example for shared memory systems
# using Mean Squared Error objective function

import daal4py as d4p
import numpy as np

import daal4py as d4p

# let's try to use pandas' fast csv reader
try:
import pandas

def read_csv(f, c, t=np.float64):
return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t)
return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t)

except ImportError:
# fall back to numpy loadtxt
def read_csv(f, c, t=np.float64):
return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2)
return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2)


def main(readcsv=read_csv, method='defaultDense'):
def main(readcsv=read_csv, method="defaultDense"):
infile = "./data/batch/mse.csv"
# Read the data, let's have 3 independent variables
data = readcsv(infile, range(3))
Expand All @@ -46,11 +48,13 @@ def main(readcsv=read_csv, method='defaultDense'):
# configure an AdaGrad object
lr = np.array([[1.0]], dtype=np.double)
niters = 1000
sgd_algo = d4p.optimization_solver_adagrad(mse_algo,
learningRate=lr,
accuracyThreshold=0.0000001,
nIterations=niters,
batchSize=1)
sgd_algo = d4p.optimization_solver_adagrad(
mse_algo,
learningRate=lr,
accuracyThreshold=0.0000001,
nIterations=niters,
batchSize=1,
)

# finally do the computation
inp = np.array([[8], [2], [1], [4]], dtype=np.double)
Expand All @@ -66,4 +70,4 @@ def main(readcsv=read_csv, method='defaultDense'):
res = main()
print("\nMinimum:\n", res.minimum)
print("\nNumber of iterations performed:\n", res.nIterations[0][0])
print('All looks good!')
print("All looks good!")
18 changes: 10 additions & 8 deletions examples/daal4py/association_rules_batch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#===============================================================================
# ===============================================================================
# Copyright 2014 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,26 +12,28 @@
# 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.
#===============================================================================
# ===============================================================================

# daal4py assiciation rules example for shared memory systems

import daal4py as d4p
import numpy as np

import daal4py as d4p

# let's try to use pandas' fast csv reader
try:
import pandas

def read_csv(f, c=None, t=np.float64):
return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t)
return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t)

except ImportError:
# fall back to numpy loadtxt
def read_csv(f, c=None, t=np.float64):
return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2)
return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2)


def main(readcsv=read_csv, method='defaultDense'):
def main(readcsv=read_csv, method="defaultDense"):
infile = "./data/batch/apriori.csv"

# configure a association_rules object
Expand All @@ -57,6 +59,6 @@ def main(readcsv=read_csv, method='defaultDense'):

if __name__ == "__main__":
result1 = main()
print('Confidence: (20 first)')
print("Confidence: (20 first)")
print(result1.confidence[0:20])
print('All looks good!')
print("All looks good!")
16 changes: 9 additions & 7 deletions examples/daal4py/bacon_outlier_batch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#===============================================================================
# ===============================================================================
# Copyright 2014 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,26 +12,28 @@
# 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.
#===============================================================================
# ===============================================================================

# daal4py outlier detection bacon example for shared memory systems

import daal4py as d4p
import numpy as np

import daal4py as d4p

# let's try to use pandas' fast csv reader
try:
import pandas

def read_csv(f, c, t=np.float64):
return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t)
return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t)

except ImportError:
# fall back to numpy loadtxt
def read_csv(f, c, t=np.float64):
return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2)
return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2)


def main(readcsv=read_csv, method='defaultDense'):
def main(readcsv=read_csv, method="defaultDense"):
# Input file
infile = "./data/batch/outlierdetection.csv"

Expand All @@ -55,4 +57,4 @@ def main(readcsv=read_csv, method='defaultDense'):

print("\nInput data\n", data)
print("\nOutlier detection result (Bacon method) weights:\n", res.weights)
print('All looks good!')
print("All looks good!")
24 changes: 13 additions & 11 deletions examples/daal4py/bf_knn_classification_batch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#===============================================================================
# ===============================================================================
# Copyright 2020 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,30 +12,33 @@
# 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.
#===============================================================================
# ===============================================================================

# daal4py Brute Force KNN example for shared memory systems

import daal4py as d4p
import numpy as np
import os

import numpy as np

import daal4py as d4p

# let's try to use pandas' fast csv reader
try:
import pandas

def read_csv(f, c, t=np.float64):
return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t)
return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t)

except ImportError:
# fall back to numpy loadtxt
def read_csv(f, c, t=np.float64):
return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2)
return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2)


def main(readcsv=read_csv, method='defaultDense'):
def main(readcsv=read_csv, method="defaultDense"):
# Input data set parameters
train_file = os.path.join('data', 'batch', 'k_nearest_neighbors_train.csv')
predict_file = os.path.join('data', 'batch', 'k_nearest_neighbors_test.csv')
train_file = os.path.join("data", "batch", "k_nearest_neighbors_train.csv")
predict_file = os.path.join("data", "batch", "k_nearest_neighbors_test.csv")

# Read data. Let's use 5 features per observation
nFeatures = 5
Expand Down Expand Up @@ -69,6 +72,5 @@ def main(readcsv=read_csv, method='defaultDense'):
print("Brute Force kNN classification results:")
print("Ground truth(observations #30-34):\n", predict_labels[30:35])
print(
"Classification results(observations #30-34):\n",
predict_result.prediction[30:35]
"Classification results(observations #30-34):\n", predict_result.prediction[30:35]
)
20 changes: 11 additions & 9 deletions examples/daal4py/brownboost_batch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#===============================================================================
# ===============================================================================
# Copyright 2014 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,26 +12,28 @@
# 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.
#===============================================================================
# ===============================================================================

# daal4py Brownboost example for shared memory systems

import daal4py as d4p
import numpy as np

import daal4py as d4p

# let's try to use pandas' fast csv reader
try:
import pandas

def read_csv(f, c, t=np.float64):
return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t)
return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t)

except ImportError:
# fall back to numpy loadtxt
def read_csv(f, c, t=np.float64):
return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2)
return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2)


def main(readcsv=read_csv, method='defaultDense'):
def main(readcsv=read_csv, method="defaultDense"):
infile = "./data/batch/brownboost_train.csv"
testfile = "./data/batch/brownboost_test.csv"

Expand All @@ -54,7 +56,7 @@ def main(readcsv=read_csv, method='defaultDense'):

# The prediction result provides prediction
assert predict_result.prediction.shape == (pdata.shape[0], dep_data.shape[1])
ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=',', ndmin=2)
ptdata = np.loadtxt(testfile, usecols=range(20, 21), delimiter=",", ndmin=2)
assert np.allclose(predict_result.prediction, ptdata)

return (train_result, predict_result, ptdata)
Expand All @@ -65,6 +67,6 @@ def main(readcsv=read_csv, method='defaultDense'):
print("\nGround truth (first 20 observations):\n", ptdata[:20])
print(
"Brownboost classification results: (first 20 observations):\n",
predict_result.prediction[:20]
predict_result.prediction[:20],
)
print('All looks good!')
print("All looks good!")
16 changes: 9 additions & 7 deletions examples/daal4py/cholesky_batch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#===============================================================================
# ===============================================================================
# Copyright 2014 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -12,26 +12,28 @@
# 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.
#===============================================================================
# ===============================================================================

# daal4py cholesky example for shared memory systems

import daal4py as d4p
import numpy as np

import daal4py as d4p

# let's try to use pandas' fast csv reader
try:
import pandas

def read_csv(f, c, t=np.float64):
return pandas.read_csv(f, usecols=c, delimiter=',', header=None, dtype=t)
return pandas.read_csv(f, usecols=c, delimiter=",", header=None, dtype=t)

except ImportError:
# fall back to numpy loadtxt
def read_csv(f, c, t=np.float64):
return np.loadtxt(f, usecols=c, delimiter=',', ndmin=2)
return np.loadtxt(f, usecols=c, delimiter=",", ndmin=2)


def main(readcsv=read_csv, method='defaultDense'):
def main(readcsv=read_csv, method="defaultDense"):
infile = "./data/batch/cholesky.csv"

# configure a cholesky object
Expand All @@ -45,4 +47,4 @@ def main(readcsv=read_csv, method='defaultDense'):
if __name__ == "__main__":
result = main()
print("\nFactor:\n", result.choleskyFactor)
print('All looks good!')
print("All looks good!")
Loading

0 comments on commit 7406562

Please sign in to comment.