Skip to content

Instantly share code, notes, and snippets.

@shoaibkamil
Created April 18, 2019 19:14
Show Gist options
  • Save shoaibkamil/27358b83931419cc20ba981f95c691ee to your computer and use it in GitHub Desktop.
Save shoaibkamil/27358b83931419cc20ba981f95c691ee to your computer and use it in GitHub Desktop.
#include "taco.h"
#include <random>
template <typename T, long L, long M, long K, long N, long O>
void taco3d(/*cTensor<T> &a, cTensor<T> &b, cTensor<T> &c*/)
{
std::default_random_engine gen(0);
std::uniform_real_distribution<T> unif(0.0, 1.0);
taco::Format rm({taco::Dense, taco::Dense, taco::Dense});
taco::Format rm4({taco::Dense,taco::Dense,taco::Dense,taco::Dense});
taco::Tensor<T> C({L, M, K}, rm);
for (int k = 0; k < C.getDimension(0); ++k)
{
for (int i = 0; i < C.getDimension(1); ++i)
{
for (int j = 0; j < C.getDimension(2); ++j)
{
C.insert({k, i, j}, unif(gen));
}
}
}
C.pack();
taco::Tensor<T> D({K, N, O}, rm);
for (int k = 0; k < D.getDimension(0); ++k)
{
for (int i = 0; i < D.getDimension(1); ++i)
{
for (int j = 0; j < D.getDimension(2); ++j)
{
D.insert({k, i, j}, unif(gen));
}
}
}
D.pack();
taco::Tensor<T> A({L, M, N, O}, rm4);
std::string mP = std::to_string(M), kP = std::to_string(K), nP = std::to_string(N), lP = std::to_string(L), oP = std::to_string(O);
//PerfEvent ev;
{
// PerfEventBlock bl(ev, countPE);
// ev.setParam("name", "Taco3D");
// ev.setParam("L", lP);
// ev.setParam("M", mP);
// ev.setParam("K", kP);
// ev.setParam("N", nP);
// ev.setParam("O", oP);
taco::IndexVar aI, bI, cI, dI, eI;
A(aI, bI, dI, eI) = C(aI, bI, cI) * D(cI, dI, eI);
A.evaluate();
}
}
int main(int argc, char* argv[]) {
taco3d<double, 100, 100, 100, 100, 10000>();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment