GithubHelp home page GithubHelp logo

Can every index be sparse? about taco HOT 8 OPEN

Llauset avatar Llauset commented on May 29, 2024
Can every index be sparse?

from taco.

Comments (8)

rohany avatar rohany commented on May 29, 2024

What schedule did you try and use with this expression and format pair? If you tried to parallelize the i loop, then the scheduling primitives available on the website will not work (such a thing is supported through the use of Assemble in the C++ API).

from taco.

Llauset avatar Llauset commented on May 29, 2024

Thank you for your answer Rohany.
I am new using TACO so for sure I am doing something wrong.
I presented the example on my first post trying to understand what it is happening if I set all the dimensions of the tensors to be sparse.
I do not understand what you mean by "shedule" or "format pair". I show you here the code I would like to run. Please, tell me if you have any sugestion about why it is not working.


  #include "taco.h"
  #include <iostream>
  
  using namespace taco;
  using namespace std;
  
  int main(int argc, char* argv[])
  {
      Format b_and_t_format({ Sparse, Sparse, Sparse });
      Format A_format({ Sparse, Sparse, Sparse, Sparse, Sparse, Sparse, Sparse });
 
      Tensor<double> B({ 3, 3, 3 }, b_and_t_format);
      Tensor<double> T({ 3, 3, 3 }, b_and_t_format);
      Tensor<double> A({ 3, 3, 3, 3, 3, 3, 3 }, A_format);
  
      B.insert({ 0, 1, 0 }, 0.5);
      B.insert({ 1, 0, 0 }, 0.5);
      B.insert({ 2, 0, 1 }, 0.5);
      B.insert({ 0, 2, 1 }, 0.5);
  
      T.insert({ 0, 0, 0 }, 1.0);
      T.insert({ 2, 1, 0 }, 1.0 / sqrt(6));
      T.insert({ 2, 1, 0 }, -1.0 / sqrt(6));
      T.insert({ 2, 0, 1 }, -1.0 / sqrt(6));
      T.insert({ 0, 2, 1 }, 1.0 / sqrt(6));
      T.insert({ 1, 0, 2 }, 1.0 / sqrt(6));
      T.insert({ 0, 1, 2 }, -1.0 / sqrt(6));
  
      // Pack data as described by the formats
      B.pack();
      T.pack();
      // Form a tensor contraction expresion
      IndexVar a, b, c, d, e, f, g, h, i, j, k;
      A(a, b, c, d, e, f, g) = B(a, h, e) * B(k, j, f) * B(d, i, g) * T(h, j, i) * T(k, b, c);
      // Compile the expression
      A.compile();
      // Assemble A's indices and numerically compute the result
      A.assemble();
      A.compute();
  }

from taco.

rohany avatar rohany commented on May 29, 2024

If you do not attempt to parallelize your code, then every index can indeed be sparse. What error do you get when running that program?

from taco.

Llauset avatar Llauset commented on May 29, 2024

Segmentation fault.
Running it with gdb I get this information about the error:
Program received signal SIGSEGV, Segmentation fault.
0x00002aaaaaf1ecbf in std::vector<taco::IndexVar, std::allocatortaco::IndexVar >::_M_erase(__gnu_cxx::__normal_iterator<taco::IndexVar*, std::vector<taco::IndexVar, std::allocatortaco::IndexVar > >) () from /tmpdir/sparse_tensors_3D/taco/build/lib/libtaco.so
Missing separate debuginfos, use: debuginfo-install glibc-2.17-326.el7_9.x86_64

Have you tried to run the code ? Are you suggesting that it has to be a problem with my environment ?
Thank you !

from taco.

rohany avatar rohany commented on May 29, 2024

Can you get a backtrace with gdb? It will be more fruitful if you compile TACO in debug mode (-DCMAKE_BUILD_TYPE=Debug) and get a backtrace.

from taco.

Llauset avatar Llauset commented on May 29, 2024

Here it is:

terminate called after throwing an instance of 'taco::TacoException'
what(): Compiler bug at /tmpdir/sparse_tensors_3D/taco/src/index_notation/transformations.cpp:1678 in topologicallySort
Please report it to developers
Condition failed: freeVarPos != std::numeric_limits<size_t>::max()
Cycles in iteration graphs must be resolved, through transpose, before the expression is passed to the topological sorting routine.

Backtrace:
#0 0x00002aaaac15a387 in raise () from /lib64/libc.so.6
#1 0x00002aaaac15ba78 in abort () from /lib64/libc.so.6
#2 0x00002aaaab8c9677 in __gnu_cxx::__verbose_terminate_handler () at ../../.././libstdc++-v3/libsupc++/vterminate.cc:95
#3 0x00002aaaab8d5116 in __cxxabiv1::__terminate(void (*)()) () at ../../.././libstdc++-v3/libsupc++/eh_terminate.cc:47
#4 0x00002aaaab8d5161 in std::terminate () at ../../.././libstdc++-v3/libsupc++/eh_terminate.cc:57
#5 0x00002aaaab8d5395 in __cxxabiv1::__cxa_throw (obj=, tinfo=0x2aaaab7f19c0 ,
dest=0x2aaaab1b66e6 taco::TacoException::~TacoException()) at ../../.././libstdc++-v3/libsupc++/eh_throw.cc:95
#6 0x00002aaaab1b65bf in taco::ErrorReport::explodeWithException (this=0x7fffffffbe30) at /tmpdir/sparse_tensors_3D/taco/src/error.cpp:65
#7 0x00002aaaab1b60b7 in taco::ErrorReport::~ErrorReport (this=0x7fffffffbe30, __in_chrg=)
at /tmpdir/sparse_tensors_3D/taco/include/taco/error.h:60
#8 0x00002aaaab336338 in taco::topologicallySort (hardDeps=..., softDeps=..., originalOrder=...)
at /tmpdir/sparse_tensors_3D/taco/src/index_notation/transformations.cpp:1678
#9 0x00002aaaab337a43 in taco::reorderLoopsTopologically (stmt=...) at /tmpdir/sparse_tensors_3D/taco/src/index_notation/transformations.cpp:1799
#10 0x00002aaaab1cfed5 in taco::TensorBase::compile (this=0x7fffffffc500) at /tmpdir/sparse_tensors_3D/taco/src/tensor.cpp:638
#11 0x0000000000404d9a in main ()

from taco.

rohany avatar rohany commented on May 29, 2024

So the first part of the problem is that TACO is getting confused by you using the same variable in multiple places in the expression (which is a bug).

Changing this

      Tensor<double> B({ 3, 3, 3 }, b_and_t_format);
      Tensor<double> T({ 3, 3, 3 }, b_and_t_format);
      Tensor<double> A({ 3, 3, 3, 3, 3, 3, 3 }, A_format);

to

      Tensor<double> B1({ 3, 3, 3 }, b_and_t_format);
      Tensor<double> B2({ 3, 3, 3 }, b_and_t_format);
      Tensor<double> B3({ 3, 3, 3 }, b_and_t_format);
      Tensor<double> T1({ 3, 3, 3 }, b_and_t_format);
      Tensor<double> T2({ 3, 3, 3 }, b_and_t_format);
      Tensor<double> A({ 3, 3, 3, 3, 3, 3, 3 }, A_format);

and this

      A(a, b, c, d, e, f, g) = B(a, h, e) * B(k, j, f) * B(d, i, g) * T(h, j, i) * T(k, b, c);

to

      A(a, b, c, d, e, f, g) = B1(a, h, e) * B2(k, j, f) * B3(d, i, g) * T1(h, j, i) * T2(k, b, c);

makes that crash go away. However, the resulting problem is more serious -- TACO spits out some invalid code:

/var/folders/b9/rl15b0d13_d4j4h9qg4tx4rr0000gn/T/taco_tmp_IcsYuV/12ef400tr7dt.c:327:31: error: use of undeclared identifier 'pA7_begin'
                          if (pA7_begin < gA) {
                              ^
/var/folders/b9/rl15b0d13_d4j4h9qg4tx4rr0000gn/T/taco_tmp_IcsYuV/12ef400tr7dt.c:342:25: error: use of undeclared identifier 'pA6_begin'
                    if (pA6_begin < fA) {
                        ^
/var/folders/b9/rl15b0d13_d4j4h9qg4tx4rr0000gn/T/taco_tmp_IcsYuV/12ef400tr7dt.c:394:9: error: use of undeclared identifier 'pA2_begin'
    if (pA2_begin < bA) {
        ^
3 errors generated.
Error at /Users/rohany/Documents/research/taco-master/src/codegen/module.cpp:156 in compile:
 Compilation command failed:

This is a harder bug to fix, and unfortunately I don't have much time to track down and fix this (maintaining TACO is not my primary obligation right now). If there's anyone else who has time cc @tensor-compiler/core-developers they could take it. Theoretically, TACO should be able to generate code for this kernel.

from taco.

Llauset avatar Llauset commented on May 29, 2024

Ok, thank you very much for your help.
I will stay tuned and if the problems are being solved I will give a try to TACO again.

from taco.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.