-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #429 from Cytnx-dev/dev-master
merge dev-master
- Loading branch information
Showing
164 changed files
with
4,959 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Tests and Codecov | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
BuildAndTest: | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
# Specify python version your environment will have. Remember to quote this, or | ||
# YAML will think you want python 3.1 not 3.10 | ||
python-version: "3.11" | ||
# This uses *miniforge*, rather than *minicond*. The primary difference is that | ||
# the defaults channel is not enabled at all | ||
miniforge-version: latest | ||
# These properties enable the use of mamba, which is much faster and far less error | ||
# prone than conda while being completely compatible with the conda CLI | ||
use-mamba: true | ||
mamba-version: "*" | ||
|
||
- name: Install dependencies | ||
shell: bash -l {0} | ||
run: | | ||
mamba install _openmp_mutex=*=*_llvm cmake make boost git compilers numpy mkl mkl-include mkl-service pybind11 libblas=*=*mkl beartype | ||
mamba install gcovr gtest | ||
- name: CPU info | ||
shell: bash -l {0} | ||
run: lscpu | ||
|
||
- name: Configure CMake | ||
shell: bash -l {0} | ||
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_INSTALL_PREFIX=/home/runner/work/Cytnx_lib -DUSE_MKL=on -DUSE_HPTT=on -DHPTT_ENABLE_FINE_TUNE=on -DHPTT_ENABLE_AVX=off -DBUILD_PYTHON=on -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DRUN_TESTS=on | ||
|
||
- name: Build | ||
shell: bash -l {0} | ||
working-directory: ${{github.workspace}}/build | ||
run: | | ||
cmake --version | ||
cmake --build . -j `nproc` | ||
- name: Install | ||
shell: bash -l {0} | ||
working-directory: ${{github.workspace}}/build | ||
run: | | ||
make install | ||
- name: Set python path | ||
run: | | ||
echo "PYTHONPATH=/home/runner/work/Cytnx_lib" >> $GITHUB_ENV | ||
- name: Test with pytest | ||
shell: bash -l {0} | ||
run: | | ||
pip install pytest pytest-cov | ||
pytest pytests/ --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html | ||
# - name: Run CTest | ||
# shell: bash -l {0} | ||
# working-directory: ${{github.workspace}}/build | ||
# run: GTEST_COLOR=1 ctest --output-on-failure --output-junit junit.xml | ||
|
||
# - name: Run gcovr | ||
# shell: bash -l {0} | ||
# working-directory: ${{github.workspace}}/build | ||
# run: | | ||
# gcovr -r .. . --xml gcovr.xml -e ".*_deps.*$" | ||
|
||
# - name: Upload coverage to Codecov | ||
# uses: codecov/codecov-action@v3 | ||
# with: | ||
# #token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos | ||
# #directory: ${{runner.workspace}}/build | ||
# files: ${{github.workspace}}/build/gcovr.xml # optional | ||
# #working-directory: ${{runner.workspace}}/build | ||
# #root_dir: ${{runner.workspace}} | ||
# fail_ci_if_error: true # optional (default = false) | ||
# verbose: true # optional (default = false) | ||
# #version: "v0.1.15" | ||
|
||
#- name: Upload gcovr files | ||
# uses: actions/upload-artifact@v3 | ||
# with: | ||
# name: CMakeError.log | ||
# path: /home/runner/work/Cytnx/Cytnx/build/CMakeFiles/CMakeError.log | ||
|
||
#- name: Upload junit files | ||
# uses: actions/upload-artifact@v3 | ||
# with: | ||
# name: junit_xml | ||
# path: ${{github.workspace}}/build/junit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
Total elem: 24 | ||
type : Double (Float64) | ||
cytnx device: CPU | ||
Shape : (2,3,4) | ||
[[[0.00000e+00 1.00000e+00 2.00000e+00 3.00000e+00 ] | ||
[4.00000e+00 5.00000e+00 6.00000e+00 7.00000e+00 ] | ||
[8.00000e+00 9.00000e+00 1.00000e+01 1.10000e+01 ]] | ||
[[1.20000e+01 1.30000e+01 1.40000e+01 1.50000e+01 ] | ||
[1.60000e+01 1.70000e+01 1.80000e+01 1.90000e+01 ] | ||
[2.00000e+01 2.10000e+01 2.20000e+01 2.30000e+01 ]]] | ||
|
||
|
||
|
||
Total elem: 6 | ||
type : Double (Float64) | ||
cytnx device: CPU | ||
Shape : (3,2) | ||
[[0.00000e+00 1.00000e+00 ] | ||
[4.00000e+00 5.00000e+00 ] | ||
[8.00000e+00 9.00000e+00 ]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "cytnx.hpp" | ||
#include <iostream> | ||
|
||
using namespace cytnx; | ||
using namespace std; | ||
int main() { | ||
// 1. handy alias: | ||
typedef Accessor ac; | ||
|
||
/* | ||
2. Create a Tensor with | ||
shape (3,4,5), | ||
dtype =Type.Double [default], | ||
device=Device.cpu [default] | ||
*/ | ||
Tensor A = cytnx::arange(24); | ||
A.reshape_({2, 3, 4}); | ||
cout << A << endl; | ||
|
||
/* | ||
3. Accessing elements using accessor | ||
This is similar as python slices. | ||
-> A[0,:,0:2:1] | ||
*/ | ||
Tensor B = A(0, ac::all(), ac::range(0, 2, 1)); | ||
cout << B << endl; | ||
|
||
/* [Note] Conversion from python slice to ac: | ||
[::x] = ac::step(x) | ||
[a::x] = ac::tilend(a,x) | ||
[a::] = ac::tilend(a) | ||
[:b:] = ac::range(0,b,1) | ||
[a:b:x] = ac::range(a,b,x) | ||
*/ | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
Total elem: 24 | ||
type : Double (Float64) | ||
cytnx device: CPU | ||
Shape : (2,3,4) | ||
[[[0.00000e+00 1.00000e+00 2.00000e+00 3.00000e+00 ] | ||
[4.00000e+00 5.00000e+00 6.00000e+00 7.00000e+00 ] | ||
[8.00000e+00 9.00000e+00 1.00000e+01 1.10000e+01 ]] | ||
[[1.20000e+01 1.30000e+01 1.40000e+01 1.50000e+01 ] | ||
[1.60000e+01 1.70000e+01 1.80000e+01 1.90000e+01 ] | ||
[2.00000e+01 2.10000e+01 2.20000e+01 2.30000e+01 ]]] | ||
|
||
|
||
|
||
Total elem: 6 | ||
type : Double (Float64) | ||
cytnx device: CPU | ||
Shape : (3,2) | ||
[[0.00000e+00 1.00000e+00 ] | ||
[4.00000e+00 5.00000e+00 ] | ||
[8.00000e+00 9.00000e+00 ]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import sys | ||
from pathlib import Path | ||
home = str(Path.home()) | ||
sys.path.append(home + '/Cytnx_lib') | ||
from cytnx import * | ||
|
||
A = arange(24); | ||
A.reshape_(2,3,4); | ||
print(A) | ||
|
||
|
||
B = A[0,:,0:2:1] | ||
print(B) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Total elem: 24 | ||
type : Double (Float64) | ||
cytnx device: CPU | ||
Shape : (2,3,4) | ||
[[[0.00000e+00 1.00000e+00 2.00000e+00 3.00000e+00 ] | ||
[4.00000e+00 5.00000e+00 6.00000e+00 7.00000e+00 ] | ||
[8.00000e+00 9.00000e+00 1.00000e+01 1.10000e+01 ]] | ||
[[1.20000e+01 1.30000e+01 1.40000e+01 1.50000e+01 ] | ||
[1.60000e+01 1.70000e+01 1.80000e+01 1.90000e+01 ] | ||
[2.00000e+01 2.10000e+01 2.20000e+01 2.30000e+01 ]]] | ||
|
||
|
||
|
||
|
||
Total elem: 6 | ||
type : Double (Float64) | ||
cytnx device: CPU | ||
Shape : (3,2) | ||
[[0.00000e+00 1.00000e+00 ] | ||
[4.00000e+00 5.00000e+00 ] | ||
[8.00000e+00 9.00000e+00 ]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Dim = 10 |type: REGULAR | ||
|
||
Dim = 5 |type: REGULAR | ||
|
||
Dim = 50 |type: REGULAR | ||
|
||
Dim = 3 |type: <BRA | ||
U1:: +0 +2 -4 | ||
Z2:: +1 +0 +1 | ||
|
||
Dim = 4 |type: <BRA | ||
U1:: +0 +2 -1 +3 | ||
Z2:: +0 +1 +1 +0 | ||
|
||
Dim = 12 |type: <BRA | ||
U1:: +0 +2 -1 +3 +2 +4 +1 +5 -4 -2 -5 -1 | ||
Z2:: +1 +0 +0 +1 +0 +1 +1 +0 +1 +0 +0 +1 |
Oops, something went wrong.