From 46ce2681056855ad3839eb77edebb9e729b86cc6 Mon Sep 17 00:00:00 2001 From: Olivia Hsu Date: Fri, 29 Sep 2023 17:39:01 -0700 Subject: [PATCH] Add in fixes to scripts --- sam/util.py | 51 ------------------- scripts/formatting/datastructure_tns.py | 2 +- .../generate_suitesparse_formats.sh | 2 +- 3 files changed, 2 insertions(+), 53 deletions(-) diff --git a/sam/util.py b/sam/util.py index 0658de93..b023147d 100644 --- a/sam/util.py +++ b/sam/util.py @@ -602,54 +602,3 @@ def safeCastPydataTensorToInts(tensor): # data[i] = int(tensor.data[i]) data[i] = round_sparse(tensor.data[i]) return sparse.COO(tensor.coords, data, tensor.shape) - - -def parse_taco_format(infilename, outdir, tensorname, format_str): - with open(infilename, 'r') as inf: - level = -1 - count = 0 - seg = True - level_done = False - for line in inf: - if count == 0: - dim_start = line.find('(') + 1 - dim_end = line.find(')') - dims = line[dim_start: dim_end] - dims = dims.split('x') - - shapefile = os.path.join(outdir, tensorname + '_shape.txt') - with open(shapefile, 'w+') as shapef: - shapef.write(array_newline_str(dims)) - else: - if line.find(':') > -1: - level += 1 - seg = True - level_done = False - else: - start = line.find('[') + 1 - end = line.find(']') - line = line[start: end] - line = line.split(', ') - - if level_done: - # This is a values array - valfile = os.path.join(outdir, tensorname + '_vals.txt') - with open(valfile, 'w+') as valf: - valf.write(array_newline_str(line)) - else: - level_format = format_str[level] - if level_format == 's': - if seg: - segfile = os.path.join(outdir, tensorname + str(level) + - '_seg.txt') - with open(segfile, 'w+') as segf: - segf.write(array_newline_str(line)) - seg = False - else: - crdfile = os.path.join(outdir, tensorname + str(level) + - '_crd.txt') - with open(crdfile, 'w+') as crdf: - crdf.write(array_newline_str(line)) - level_done = True - - count += 1 diff --git a/scripts/formatting/datastructure_tns.py b/scripts/formatting/datastructure_tns.py index aede2dbc..7ff46056 100644 --- a/scripts/formatting/datastructure_tns.py +++ b/scripts/formatting/datastructure_tns.py @@ -1,7 +1,7 @@ import argparse import os from pathlib import Path -from sam.util import parse_taco_format +from scripts.util.util import parse_taco_format cwd = os.getcwd() diff --git a/scripts/formatting/generate_suitesparse_formats.sh b/scripts/formatting/generate_suitesparse_formats.sh index 8e74b9a1..3776800c 100755 --- a/scripts/formatting/generate_suitesparse_formats.sh +++ b/scripts/formatting/generate_suitesparse_formats.sh @@ -22,7 +22,7 @@ OTHERBENCHES='["mat_residual", "mat_mattransmul", "mat_vecmul"]' # THIS FILE MUST BE RUN FROM sam/ location outdir=${SUITESPARSE_FORMATTED_PATH} basedir=$(pwd) -textfile=$basedir/scripts/tensor_names/$1 +textfile=$basedir/$1 mkdir -p $outdir cd $outdir