Skip to content

Implement 'einsum' to overcome intrinsic limitation of 'tensordot' #1224

@tdegeus

Description

@tdegeus

I am trying to evaluate the following partial contraction

c(e,q,i,j) = a(e,q,i,j,k,l) * b(e,q,l,k)

using

#include <xtensor/xtensor.hpp>
#include <xtensor/xio.hpp>
#include <xtensor/xrandom.hpp>
#include <xtensor-blas/xlinalg.hpp>

int main()
{
  xt::xtensor<double,6> a = xt::random::rand<double>({1,4,2,2,2,2});
  xt::xtensor<double,4> b = xt::random::rand<double>({1,4,2,2    });

  auto c = xt::linalg::tensordot(a,b,{5,2},{4,3});
}

But this gives me the error that

libc++abi.dylib: terminating with uncaught exception of type xt::transpose_error: Permutation does not have the same size as shape

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions