Skip to content

[mlir][sparse] remove the MLIR PyTACO tests #66302

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

Merged
merged 1 commit into from
Sep 13, 2023
Merged

Conversation

aartbik
Copy link
Contributor

@aartbik aartbik commented Sep 13, 2023

Rationale:

This test was really fun to compare the MLIR sparsifier with TACO using the PyTACO format. However, the underlying mechanism is rapidly growing outdated with our recent developments. Rather than maintaining the old code, we are moving toward the newer, better approaches. So if you are sad this is gone, stay tuned, something better is coming!

Rationale:

This test was really fun to compare the MLIR sparsifier
with TACO using the PyTACO format. However, the underlying
mechanism is rapidly growing outdated with our recent
developments. Rather than maintaining the old code, we
are moving toward the newer, better approaches. So if you
are sad this is gone, stay tuned, something better is coming!
@aartbik aartbik requested a review from a team as a code owner September 13, 2023 22:36
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir:sparse Sparse compiler in MLIR mlir labels Sep 13, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 13, 2023

@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir-sparse

Changes Rationale:

This test was really fun to compare the MLIR sparsifier with TACO using the PyTACO format. However, the underlying mechanism is rapidly growing outdated with our recent developments. Rather than maintaining the old code, we are moving toward the newer, better approaches. So if you are sad this is gone, stay tuned, something better is coming!

Patch is 167.49 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/66302.diff

30 Files Affected:

  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/README.md (-27)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/data/A.mtx (-11)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/data/B.mtx (-11)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_A.tns (-53)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_C.tns (-12)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_y.tns (-6)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/data/nell-2.tns (-10)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/data/pwtk.mtx (-14)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/lit.local.cfg (-5)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_MTTKRP.py (-55)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_SDDMM.py (-58)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_SpMM.py (-35)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_SpMV.py (-56)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_Tensor.py (-99)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_scalar_tensor_algebra.py (-36)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_simple_tensor_algebra.py (-61)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_tensor_complex.py (-31)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_tensor_types.py (-33)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_tensor_unary_ops.py (-40)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/test_true_dense_tensor_algebra.py (-22)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/tools/lit.local.cfg (-2)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco.py (-2279)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco_api.py (-53)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco_io.py (-82)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_pytaco_utils.py (-424)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/tools/mlir_sparse_compiler.py (-41)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/tools/testing_utils.py (-47)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/unit_test_tensor_core.py (-647)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/unit_test_tensor_io.py (-116)
  • (removed) mlir/test/Integration/Dialect/SparseTensor/taco/unit_test_tensor_utils.py (-135)

<pre>
diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/README.md b/mlir/test/Integration/Dialect/SparseTensor/taco/README.md
deleted file mode 100644
index 88a8ce258196202..000000000000000
--- a/mlir/test/Integration/Dialect/SparseTensor/taco/README.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# MLIR-PyTACO: Implementing PyTACO with MLIR

-TACO (http://tensor-compiler.org/) is a tensor algebra compiler. TACO defines
-PyTACO, a domain specific language in Python, for writing tensor algebra
-applications.

-This directory contains the implementation of PyTACO using MLIR. In particular,
-we implement a Python layer that accepts the PyTACO language, generates MLIR
-linalg.generic OPs with sparse tensor annotation to represent the tensor
-computation, and invokes the MLIR sparse tensor code generator
-(https://mlir.llvm.org/docs/Dialects/SparseTensorOps/) as well as other MLIR
-compilation passes to generate an executable. Then, we invoke the MLIR execution
-engine to execute the program and pass the result back to the Python layer.

-As can be seen from the tests in this directory, in order to port a PyTACO
-program to MLIR-PyTACO, we basically only need to replace this line that imports
-PyTACO:

-python -import pytaco as pt -

-with this line to import MLIR-PyTACO:

-python -from tools import mlir_pytaco_api as pt -
diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/data/A.mtx b/mlir/test/Integration/Dialect/SparseTensor/taco/data/A.mtx
deleted file mode 100644
index 6ea0893af616432..000000000000000
--- a/mlir/test/Integration/Dialect/SparseTensor/taco/data/A.mtx
+++ /dev/null
@@ -1,11 +0,0 @@
-%%MatrixMarket matrix coordinate real general
-3 3 9
-1 1 1.0
-1 2 2.0
-1 3 4.0
-2 1 4.0
-2 2 5.0
-2 3 6.0
-3 1 7.0
-3 2 8.0
-3 3 9.0
diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/data/B.mtx b/mlir/test/Integration/Dialect/SparseTensor/taco/data/B.mtx
deleted file mode 100644
index 9bb604d44c7c9f5..000000000000000
--- a/mlir/test/Integration/Dialect/SparseTensor/taco/data/B.mtx
+++ /dev/null
@@ -1,11 +0,0 @@
-%%MatrixMarket matrix coordinate real general
-3 3 9
-1 1 10.0
-1 2 11.0
-1 3 12.0
-2 1 13.0
-2 2 14.0
-2 3 15.0
-3 1 16.0
-3 2 17.0
-3 3 18.0
diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_A.tns b/mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_A.tns
deleted file mode 100644
index f06646b51feca77..000000000000000
--- a/mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_A.tns
+++ /dev/null
@@ -1,53 +0,0 @@
-# See http://frostt.io/tensors/file-formats.html for FROSTT (.tns) format
-2 50
-2 25
-1 1 12
-1 2 12
-1 3 12
-1 4 12
-1 5 12
-1 6 12
-1 7 12
-1 8 12
-1 9 12
-1 10 12
-1 11 12
-1 12 12
-1 13 12
-1 14 12
-1 15 12
-1 16 12
-1 17 12
-1 18 12
-1 19 12
-1 20 12
-1 21 12
-1 22 12
-1 23 12
-1 24 12
-1 25 12
-2 1 6
-2 2 6
-2 3 6
-2 4 6
-2 5 6
-2 6 6
-2 7 6
-2 8 6
-2 9 6
-2 10 6
-2 11 6
-2 12 6
-2 13 6
-2 14 6
-2 15 6
-2 16 6
-2 17 6
-2 18 6
-2 19 6
-2 20 6
-2 21 6
-2 22 6
-2 23 6
-2 24 6
-2 25 6
diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_C.tns b/mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_C.tns
deleted file mode 100644
index 61bec5dece95121..000000000000000
--- a/mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_C.tns
+++ /dev/null
@@ -1,12 +0,0 @@
-# See http://frostt.io/tensors/file-formats.html for FROSTT (.tns) format
-2 9
-3 3
-1 1 100
-1 2 107
-1 3 114
-2 1 201
-2 2 216
-2 3 231
-3 1 318
-3 2 342
-3 3 366
diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_y.tns b/mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_y.tns
deleted file mode 100644
index 832cb1795aaaa25..000000000000000
--- a/mlir/test/Integration/Dialect/SparseTensor/taco/data/gold_y.tns
+++ /dev/null
@@ -1,6 +0,0 @@
-# See http://frostt.io/tensors/file-formats.html for FROSTT (.tns) format
-1 3
-3
-1 37102
-2 -20.4138
-3 804927
diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/data/nell-2.tns b/mlir/test/Integration/Dialect/SparseTensor/taco/data/nell-2.tns
deleted file mode 100644
index b82ce864820fba3..000000000000000
--- a/mlir/test/Integration/Dialect/SparseTensor/taco/data/nell-2.tns
+++ /dev/null
@@ -1,10 +0,0 @@
-# Extended FROSTT format:
-# rank number-non-zero-elements
-# dimension-sizes
-3 5
-2 4 4
-1 1 1 1.0
-1 2 2 2.0
-1 3 4 3.0
-2 1 1 1.0
-2 4 3 2.0
diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/data/pwtk.mtx b/mlir/test/Integration/Dialect/SparseTensor/taco/data/pwtk.mtx
deleted file mode 100644
index c207a8681c4e9ea..000000000000000
--- a/mlir/test/Integration/Dialect/SparseTensor/taco/data/pwtk.mtx
+++ /dev/null
@@ -1,14 +0,0 @@
-%%MatrixMarket matrix coordinate real general
-%-------------------------------------------------------------------------------
-% To download a matrix for a real world application
-% https://math.nist.gov/MatrixMarket/
-%-------------------------------------------------------------------------------
-3 3 8
-1 1 37423.0879671
-1 2 -22.4050781162
-1 3 -300.654980157
-2 1 -22.4050781162
-2 3 -.00869762944058
-3 1 -300.654980157
-3 2 -.00869762944058
-3 3 805225.750212
diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/lit.local.cfg b/mlir/test/Integration/Dialect/SparseTensor/taco/lit.local.cfg
deleted file mode 100644
index f1bbcf486bc2705..000000000000000
--- a/mlir/test/Integration/Dialect/SparseTensor/taco/lit.local.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-# Disable ASAN&#x27;s leak detection for python taco tests.
-config.environment[&quot;ASAN_OPTIONS&quot;] = &quot;detect_leaks=0&quot;
-# Only run when python bindings are enabled.
-if not config.enable_bindings_python:

  • config.unsupported = True
    diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/test_MTTKRP.py b/mlir/test/Integration/Dialect/SparseTensor/taco/test_MTTKRP.py
    deleted file mode 100644
    index 2d558f8d6ddff4d..000000000000000
    --- a/mlir/test/Integration/Dialect/SparseTensor/taco/test_MTTKRP.py
    +++ /dev/null
    @@ -1,55 +0,0 @@
    -# RUN: env SUPPORTLIB=%mlir_c_runner_utils %PYTHON %s | FileCheck %s

-import numpy as np
-import os
-import sys
-import tempfile

-_SCRIPT_PATH = os.path.dirname(os.path.abspath(file))
-sys.path.append(_SCRIPT_PATH)

-from tools import mlir_pytaco_api as pt
-from tools import testing_utils as utils

-###### This PyTACO part is taken from the TACO open-source project. ######
-# See http://tensor-compiler.org/docs/data_analytics/index.html.

-compressed = pt.compressed
-dense = pt.dense

-# Define formats for storing the sparse tensor and dense matrices.
-csf = pt.format([compressed, compressed, compressed])
-rm = pt.format([dense, dense])

-# Load a sparse three-dimensional tensor from file (stored in the FROSTT
-# format) and store it as a compressed sparse fiber tensor. We use a small
-# tensor for the purpose of testing. To run the program using the data from
-# the real application, please download the data from:
-# http://frostt.io/tensors/nell-2/
-B = pt.read(os.path.join(_SCRIPT_PATH, &quot;data/nell-2.tns&quot;), csf)

-# These two lines have been modified from the original program to use static
-# data to support result comparison.
-C = pt.from_array(np.full((B.shape[1], 25), 1, dtype=np.float32))
-D = pt.from_array(np.full((B.shape[2], 25), 2, dtype=np.float32))

-# Declare the result to be a dense matrix.
-A = pt.tensor([B.shape[0], 25], rm)

-# Declare index vars.
-i, j, k, l = pt.get_index_vars(4)

-# Define the MTTKRP computation.
-A[i, j] = B[i, k, l] * D[l, j] * C[k, j]

-##########################################################################

-# Perform the MTTKRP computation and write the result to file.
-with tempfile.TemporaryDirectory() as test_dir:

  • golden_file = os.path.join(_SCRIPT_PATH, &quot;data/gold_A.tns&quot;)
  • out_file = os.path.join(test_dir, &quot;A.tns&quot;)
  • pt.write(out_file, A)
  • CHECK: Compare result True

  • print(f&quot;Compare result {utils.compare_sparse_tns(golden_file, out_file)}&quot;)
    diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/test_SDDMM.py b/mlir/test/Integration/Dialect/SparseTensor/taco/test_SDDMM.py
    deleted file mode 100644
    index ef94ea9900fe496..000000000000000
    --- a/mlir/test/Integration/Dialect/SparseTensor/taco/test_SDDMM.py
    +++ /dev/null
    @@ -1,58 +0,0 @@
    -# RUN: env SUPPORTLIB=%mlir_c_runner_utils %PYTHON %s | FileCheck %s

-import filecmp
-import numpy as np
-import os
-import sys
-import tempfile

-_SCRIPT_PATH = os.path.dirname(os.path.abspath(file))
-sys.path.append(_SCRIPT_PATH)

-from tools import mlir_pytaco_api as pt
-from tools import testing_utils as utils

-i, j, k = pt.get_index_vars(3)

-# Set up dense matrices.
-A = pt.from_array(np.full((8, 8), 2.0, dtype=np.float32))
-B = pt.from_array(np.full((8, 8), 3.0, dtype=np.float32))

-# Set up sparse matrices.
-S = pt.tensor([8, 8], pt.format([pt.compressed, pt.compressed]))
-X = pt.tensor([8, 8], pt.format([pt.compressed, pt.compressed]))
-Y = pt.tensor([8, 8], pt.compressed) # alternative syntax works too

-S.insert([0, 7], 42.0)

-# Define the SDDMM kernel. Since this performs the reduction as
-# sum(k, S[i, j] * A[i, k] * B[k, j])
-# we only compute the intermediate dense matrix product that are actually
-# needed to compute the result, with proper asymptotic complexity.
-X[i, j] = S[i, j] * A[i, k] * B[k, j]

-# Alternative way to define SDDMM kernel. Since this performs the reduction as
-# sum(k, A[i, k] * B[k, j]) * S[i, j]
-# the MLIR lowering results in two separate tensor index expressions that are
-# fused prior to running the sparse compiler in order to guarantee proper
-# asymptotic complexity.
-Y[i, j] = A[i, k] * B[k, j] * S[i, j]

-expected = &quot;&quot;&quot;; extended FROSTT format
-2 1
-8 8
-1 8 2016
-&quot;&quot;&quot;

-# Force evaluation of the kernels by writing out X and Y.
-with tempfile.TemporaryDirectory() as test_dir:

  • x_file = os.path.join(test_dir, &quot;X.tns&quot;)
  • y_file = os.path.join(test_dir, &quot;Y.tns&quot;)
  • pt.write(x_file, X)
  • pt.write(y_file, Y)
  • CHECK: Compare result True True

  • x_data = utils.file_as_string(x_file)
  • y_data = utils.file_as_string(y_file)
  • print(f&quot;Compare result {x_data == expected} {y_data == expected}&quot;)
    diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/test_SpMM.py b/mlir/test/Integration/Dialect/SparseTensor/taco/test_SpMM.py
    deleted file mode 100644
    index 02bbbc096e7a3ea..000000000000000
    --- a/mlir/test/Integration/Dialect/SparseTensor/taco/test_SpMM.py
    +++ /dev/null
    @@ -1,35 +0,0 @@
    -# RUN: env SUPPORTLIB=%mlir_c_runner_utils %PYTHON %s | FileCheck %s

-import filecmp
-import numpy as np
-import os
-import sys
-import tempfile

-_SCRIPT_PATH = os.path.dirname(os.path.abspath(file))
-sys.path.append(_SCRIPT_PATH)

-from tools import mlir_pytaco_api as pt
-from tools import testing_utils as utils

-# Define the CSR format.
-csr = pt.format([pt.dense, pt.compressed], [0, 1])

-# Read matrices A and B from file, infer size of output matrix C.
-A = pt.read(os.path.join(_SCRIPT_PATH, &quot;data/A.mtx&quot;), csr)
-B = pt.read(os.path.join(_SCRIPT_PATH, &quot;data/B.mtx&quot;), csr)
-C = pt.tensor([A.shape[0], B.shape[1]], csr)

-# Define the kernel.
-i, j, k = pt.get_index_vars(3)
-C[i, j] = A[i, k] * B[k, j]

-# Force evaluation of the kernel by writing out C.
-with tempfile.TemporaryDirectory() as test_dir:

  • golden_file = os.path.join(_SCRIPT_PATH, &quot;data/gold_C.tns&quot;)
  • out_file = os.path.join(test_dir, &quot;C.tns&quot;)
  • pt.write(out_file, C)
  • CHECK: Compare result True

  • print(f&quot;Compare result {utils.compare_sparse_tns(golden_file, out_file)}&quot;)
    diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/test_SpMV.py b/mlir/test/Integration/Dialect/SparseTensor/taco/test_SpMV.py
    deleted file mode 100644
    index 2038a473ae53030..000000000000000
    --- a/mlir/test/Integration/Dialect/SparseTensor/taco/test_SpMV.py
    +++ /dev/null
    @@ -1,56 +0,0 @@
    -# RUN: env SUPPORTLIB=%mlir_c_runner_utils %PYTHON %s | FileCheck %s

-import numpy as np
-import os
-import sys
-import tempfile

-_SCRIPT_PATH = os.path.dirname(os.path.abspath(file))
-sys.path.append(_SCRIPT_PATH)

-from tools import mlir_pytaco_api as pt
-from tools import testing_utils as utils

-###### This PyTACO part is taken from the TACO open-source project. ######
-# See http://tensor-compiler.org/docs/scientific_computing/index.html.

-compressed = pt.compressed
-dense = pt.dense

-# Define formats for storing the sparse matrix and dense vectors.
-csr = pt.format([dense, compressed])
-dv = pt.format([dense])

-# Load a sparse matrix stored in the matrix market format) and store it
-# as a CSR matrix. The matrix in this test is a reduced version of the data
-# downloaded from here:
-# https://www.cise.ufl.edu/research/sparse/MM/Boeing/pwtk.tar.gz
-# In order to run the program using the matrix above, you can download the
-# matrix and replace this path to the actual path to the file.
-A = pt.read(os.path.join(_SCRIPT_PATH, &quot;data/pwtk.mtx&quot;), csr)

-# These two lines have been modified from the original program to use static
-# data to support result comparison.
-x = pt.from_array(np.full((A.shape[1],), 1, dtype=np.float32))
-z = pt.from_array(np.full((A.shape[0],), 2, dtype=np.float32))

-# Declare the result to be a dense vector
-y = pt.tensor([A.shape[0]], dv)

-# Declare index vars
-i, j = pt.get_index_vars(2)

-# Define the SpMV computation
-y[i] = A[i, j] * x[j] + z[i]

-##########################################################################

-# Perform the SpMV computation and write the result to file
-with tempfile.TemporaryDirectory() as test_dir:

  • golden_file = os.path.join(_SCRIPT_PATH, &quot;data/gold_y.tns&quot;)
  • out_file = os.path.join(test_dir, &quot;y.tns&quot;)
  • pt.write(out_file, y)
  • CHECK: Compare result True

  • print(f&quot;Compare result {utils.compare_sparse_tns(golden_file, out_file)}&quot;)
    diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/test_Tensor.py b/mlir/test/Integration/Dialect/SparseTensor/taco/test_Tensor.py
    deleted file mode 100644
    index cd24e0dbb0a43ae..000000000000000
    --- a/mlir/test/Integration/Dialect/SparseTensor/taco/test_Tensor.py
    +++ /dev/null
    @@ -1,99 +0,0 @@
    -# RUN: env SUPPORTLIB=%mlir_c_runner_utils %PYTHON %s | FileCheck %s

-import filecmp
-import numpy as np
-import os
-import sys
-import tempfile

-_SCRIPT_PATH = os.path.dirname(os.path.abspath(file))
-sys.path.append(_SCRIPT_PATH)

-from tools import mlir_pytaco_api as pt
-from tools import testing_utils as utils

-i, j, k, l, m = pt.get_index_vars(5)

-# Set up scalar.
-alpha = pt.tensor(42.0)

-# Set up some sparse tensors with different dim annotations and ordering.
-S = pt.tensor([8, 8, 8], pt.format([pt.compressed, pt.dense, pt.compressed], [1, 0, 2]))
-X = pt.tensor(

  • [8, 8, 8], pt.format([pt.compressed, pt.compressed, pt.compressed], [1, 0, 2])
    -)
    -S.insert([0, 0, 0], 2.0)
    -S.insert([1, 1, 1], 3.0)
    -S.insert([4, 4, 4], 4.0)
    -S.insert([7, 7, 7], 5.0)

-X[i, j, k] = alpha[0] * S[i, j, k]

-# Set up tensors with a dense last dimension. This results in a full
-# enveloping storage of all last &quot;rows&quot; with one or more nonzeros.
-T = pt.tensor(

  • [1, 2, 3, 4, 5],
  • pt.format([pt.compressed, pt.compressed, pt.compressed, pt.compressed, pt.dense]),
    -)
    -Y = pt.tensor(
  • [1, 2, 3, 4, 5],
  • pt.format([pt.compressed, pt.compressed, pt.compressed, pt.compressed, pt.dense]),
    -)
    -T.insert([0, 1, 2, 3, 4], -2.0)

-Y[i, j, k, l, m] = alpha[0] * T[i, j, k, l, m]

-# Set up a sparse tensor and dense tensor with different access.
-U = pt.tensor([2, 3], pt.format([pt.compressed, pt.compressed], [1, 0]))
-Z = pt.tensor([3, 2], pt.format([pt.dense, pt.dense]))
-U.insert([1, 2], 3.0)

-Z[i, j] = alpha[0] * U[j, i]

-x_expected = &quot;&quot;&quot;; extended FROSTT format
-3 4
-8 8 8
-1 1 1 84
-2 2 2 126
-5 5 5 168
-8 8 8 210
-&quot;&quot;&quot;

-y_expected = &quot;&quot;&quot;; extended FROSTT format
-5 5
-1 2 3 4 5
-1 2 3 4 1 0
-1 2 3 4 2 0
-1 2 3 4 3 0
-1 2 3 4 4 0
-1 2 3 4 5 -84
-&quot;&quot;&quot;

-z_expected = &quot;&quot;&quot;; extended FROSTT format
-2 6
-3 2
-1 1 0
-1 2 0
-2 1 0
-2 2 0
-3 1 0
-3 2 126
-&quot;&quot;&quot;

-# Force evaluation of the kernel by writing out X.
-with tempfile.TemporaryDirectory() as test_dir:

  • x_file = os.path.join(test_dir, &quot;X.tns&quot;)
  • pt.write(x_file, X)
  • y_file = os.path.join(test_dir, &quot;Y.tns&quot;)
  • pt.write(y_file, Y)
  • z_file = os.path.join(test_dir, &quot;Z.tns&quot;)
  • pt.write(z_file, Z)
  • CHECK: Compare result True True True

  • x_data = utils.file_as_string(x_file)
  • y_data = utils.file_as_string(y_file)
  • z_data = utils.file_as_string(z_file)
  • print(
  •    f&amp;quot;Compare result {x_data == x_expected} {y_data == y_expected} {z_data == z_expected}&amp;quot;
    
  • )
    diff --git a/mlir/test/Integration/Dialect/SparseTensor/taco/test_scalar_tensor_algebra.py b/mlir/test/Integration/Dialect/SparseTensor/taco/test_scalar_tensor_algebra.py
    deleted file mode 100644
    index 206ffa9316d48f4..000000000000000
    --- a/mlir/test/Integration/Dialect/SparseTensor/taco/test_scalar_tensor_algebra.py
    +++ /dev/null
    @@ -1,36 +0,0 @@
    -# RUN: env SUPPORTLIB=%mlir_c_runner_utils %PYTHON %s | FileCheck %s

-import numpy as np
-import os
-import sys

-_SCRIPT_PATH = os.path.dirname(os.path.abspath(file))
-sys.path.append(_SCRIPT_PATH)
-from tools import mlir_pytaco_api as pt

-compressed = pt.compressed

-i, j = pt.get_index_vars(2)
-A = pt.tensor([2, 3])
-S = pt.tensor(3) # S is a scalar tensor.
-B = pt.tensor([2, 3], compressed)
-A.insert([0, 1], 10)
-A.insert([1, 2], 40)

-# U...

@aartbik
Copy link
Contributor Author

aartbik commented Sep 13, 2023

Ignoring the Python formatting checks on just removed code ;-)

@aartbik aartbik merged commit 0f65df7 into llvm:main Sep 13, 2023
@aartbik aartbik deleted the pytaco branch September 13, 2023 22:54
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
Rationale:

This test was really fun to compare the MLIR sparsifier with TACO using
the PyTACO format. However, the underlying mechanism is rapidly growing
outdated with our recent developments. Rather than maintaining the old
code, we are moving toward the newer, better approaches. So if you are
sad this is gone, stay tuned, something better is coming!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir:sparse Sparse compiler in MLIR mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants