Skip to content

Instantly share code, notes, and snippets.

@prigoyal
Created March 6, 2018 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prigoyal/0a0ad421d50f31ad8a37ef0f9d0dc150 to your computer and use it in GitHub Desktop.
Save prigoyal/0a0ad421d50f31ad8a37ef0f9d0dc150 to your computer and use it in GitHub Desktop.
TEST_F(ATenCompilationUnitTest, TuckerConv) {
at::Tensor core = at::CUDA(at::kFloat).rand({32, 10, 10, 10});
at::Tensor X = at::CUDA(at::kFloat).rand({32, 10, 128});
at::Tensor Y = at::CUDA(at::kFloat).rand({32, 10, 128});
at::Tensor Z = at::CUDA(at::kFloat).rand({32, 10, 64});
at::Tensor weight = at::CUDA(at::kFloat).rand({128, 64, 3, 3});
std::vector<at::Tensor> inputs = {core, X, Y, Z, weight};
std::vector<at::Tensor> outputs;
static constexpr auto TC = R"TC(
def tuckerconv(float(B,R,R,R) CORE, float(B,R,H) X, float(B,R,W) Y, float(B,R,I) Z, float(O,I,KH,KW) WEIGHT) -> (Out) {
Out(b,o,h,w) +=! CORE(b,r1,r2,r3) * X(b,r1,h+kh) * Y(b,r2,w+kw) * Z(b,r3,i) * WEIGHT(o,i,kh,kw)
}
)TC";
auto options = tc::MappingOptions::makeNaiveMappingOptions();
auto name = "tuckerconv";
std::string cacheFilename = "";
autotune(cacheFilename, TC, name, inputs, options, {options});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment