Tensor Comprehensions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
matmul_op.h
Go to the documentation of this file.
1 
16 #pragma once
17 
18 #include <string>
19 #include <vector>
20 
21 #include "tc/c2/tc_op.h"
22 #include "tc/library/matmul.h"
23 
24 namespace caffe2 {
25 
26 template <typename T, class Context, class Engine = caffe2::DefaultEngine>
27 class TcMatMulOp : public TcOp<T, Context, Engine> {
28  public:
29  static constexpr auto description = tc::TC_MATMUL;
30 
31  TcMatMulOp(const caffe2::OperatorDef& operator_def, caffe2::Workspace* ws)
32  : TcOp<T, Context, Engine>(operator_def, ws) {
33  bool trans_a = OperatorBase::GetSingleArgument<int>("trans_a", 0);
34  bool trans_b = OperatorBase::GetSingleArgument<int>("trans_b", 0);
35  this->tc_ = tc::makeMatmulTc(trans_a, trans_b);
36  this->tcName_ = tc::TC_MATMUL_NAME;
37  }
38 
39  ~TcMatMulOp() override {}
40 
41  protected:
42  void setupNaiveMappingOptions() override {
43  this->mappingOptions_.tile({16, 16, 32})
44  .mapToThreads(4, 32)
45  .mapToBlocks(32, 32, 32)
46  .unroll(1);
47  }
48 };
49 } // namespace caffe2
tc::MappingOptions mappingOptions_
Definition: tc_op.h:133
Definition: matmul_op.h:27
static constexpr auto description
Definition: matmul_op.h:29
MappingOptions & unroll(uint64_t size)
Definition: mapping_options-inl.h:321
Definition: tc_op.h:36
~TcMatMulOp() override
Definition: matmul_op.h:39
TcMatMulOp(const caffe2::OperatorDef &operator_def, caffe2::Workspace *ws)
Definition: matmul_op.h:31
MappingOptions & mapToBlocks(std::initializer_list< uint64_t > blocks)
Definition: mapping_options-inl.h:297
std::string tc_
Definition: tc_op.h:128
std::string tcName_
Definition: tc_op.h:130
std::string makeMatmulTc(bool transposeFirst=false, bool transposeSecond=false)
Definition: matmul.h:32
MappingOptions & tile(const std::vector< uint64_t > &sizes)
Definition: mapping_options-inl.h:251
void setupNaiveMappingOptions() override
Definition: matmul_op.h:42