Skip to content

Commit

Permalink
Test CICD 7
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasReutelsterz committed Jun 12, 2024
1 parent 5af2070 commit f6c060a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/code-gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(PRECISION "double" CACHE STRING "floating point type: double/single")
set(PRECISION_OPTIONS "double" "single")
set_property(CACHE PRECISION PROPERTY STRINGS ${PRECISION_OPTIONS})

set(ARCH "hsw" CACHE STRING "floating point type: double/single")
set(ARCH "snb" CACHE STRING "floating point type: double/single")
set(ARCH_OPTIONS snb hsw skx thunderx2t99 nvidia)
set_property(CACHE ARCH PROPERTY STRINGS ${ARCH_OPTIONS})

Expand Down
24 changes: 20 additions & 4 deletions tests/code-gen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
cmdLineParser.add_argument('--variant', type=str, default='', help='Example specific variant OpenBLAS, LIBXSMM.')
cmdLineParser.add_argument('--output_dir', type=str, default='./', help='output directory for gen. code')
cmdLineParser.add_argument('example_script', type=str, help='A tensorforge example script from the examples folder (without file extension).')
cmdLineParser.add_argument('--backend', type = str, default='cuda', help='Backend (e.g. cuda).')
cmdLineParser.add_argument('--backend', type = str, help='Backend (e.g. cuda).')
cmdLineArgs = cmdLineParser.parse_args()

exampleSpec = importlib.util.find_spec(cmdLineArgs.example_script)
Expand All @@ -38,11 +38,26 @@
if e.errno == errno.EEXIST:
pass

#Currently shsw as host_arch
arch = useArchitectureIdentifiedBy('shsw', cmdLineArgs.arch, cmdLineArgs.backend)
script_dir = os.path.dirname(os.path.realpath(__file__))
db_file_path = os.path.join(script_dir, '/../../tensorforge/arch_db.yml')
with open(db_file_path, 'r') as file:
yaml_data = yaml.safe_load(file)
cpu_archs = [item['arch'] for item in yaml_data]
if any(substring in cmdLineArgs.arch for substring in cpu_archs):
target = 'cpu'


if cmdLineArgs.backend:
#Currently shsw as host_arch
arch = useArchitectureIdentifiedBy('shsw', cmdLineArgs.arch, cmdLineArgs.backend)
elif target == 'cpu':
arch = useArchitectureIdentifiedBy('shsw', cmdLineArgs.arch, 'cpp')
else:
target = 'gpu'
arch = useArchitectureIdentifiedBy(cmdLineArgs.arch, cmdLineArgs.arch, 'cuda')

g = Generator(arch)
example.add(g)
example.add(g, target)

gemm_cfg = example.gemm_cfg(arch, cmdLineArgs.variant) if hasattr(example, 'gemm_cfg') else None
g.generate(outDir, gemm_cfg=gemm_cfg)
Expand Down Expand Up @@ -134,3 +149,4 @@
if trashTheCache:
cpp('delete[] _trash;')
cpp('return 0;')

10 changes: 5 additions & 5 deletions tests/code-gen/matmul.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

from tensorforge import *

def add(g):
def add(g, target_input):
M = 32
N = 32
K = 32
A = Tensor('A', (M, K))
B = Tensor('B', (K, N))
C = Tensor('C', (M, N))

g.add('matmulAB', C['ij'] <= A['ik'] * B['kj'], target = 'gpu')
g.add('matmulATB', C['ij'] <= A['ki'] * B['kj'], target = 'gpu')
g.add('matmulABT', C['ij'] <= A['ik'] * B['jk'], target = 'gpu')
g.add('matmulATBT', C['ij'] <= A['ki'] * B['jk'], target = 'gpu')
g.add('matmulAB', C['ij'] <= A['ik'] * B['kj'], target = target_input)
g.add('matmulATB', C['ij'] <= A['ki'] * B['kj'], target = target_input)
g.add('matmulABT', C['ij'] <= A['ik'] * B['jk'], target = target_input)
g.add('matmulATBT', C['ij'] <= A['ki'] * B['jk'], target = target_input)
4 changes: 2 additions & 2 deletions tests/code-gen/minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from tensorforge import *

def add(g):
def add(g, target_input):
N = 8
A = Tensor('A', (N, N))
B = Tensor('B', (N, N, N))
w = Tensor('w', (N,))
C = Tensor('C', (N, N))

kernel = C['ij'] <= 2.0 * C['ij'] + A['lj'] * B['ikl'] * w['k']
g.add('kernel', kernel, target = "gpu")
g.add('kernel', kernel, target = target_input)

0 comments on commit f6c060a

Please sign in to comment.