InfiniOps
Operator Library for Accelerators
Loading...
Searching...
No Matches
matmul.h
Go to the documentation of this file.
1#ifndef INFINI_OPS_BASE_MATMUL_H_
2#define INFINI_OPS_BASE_MATMUL_H_
3
4#include "operator.h"
5#include "tensor.h"
6
7namespace infini::ops {
8
9class Matmul : public Operator<Matmul> {
10 public:
11 Matmul(const Tensor input, const Tensor other, Tensor out)
12 : input_shape_{input.shape()},
13 input_strides_{input.strides()},
14 input_type_{input.dtype()},
15 other_shape_{other.shape()},
16 other_strides_{other.strides()},
17 other_type_{other.dtype()},
18 out_shape_{out.shape()},
19 out_strides_{out.strides()},
20 out_type_{out.dtype()} {
21 assert(input.dtype() == other.dtype() &&
22 "operator `Matmul` requires inputs to have the same dtype");
23 assert(input.dtype() == out.dtype() &&
24 "operator `Matmul` requires output to have the input dtype");
25 }
26
27 virtual void operator()(const Tensor input, const Tensor other,
28 Tensor out) const = 0;
29
30 protected:
31 Tensor::Shape input_shape_;
32
33 Tensor::Strides input_strides_;
34
35 DataType input_type_;
36
37 Tensor::Shape other_shape_;
38
39 Tensor::Strides other_strides_;
40
41 DataType other_type_;
42
43 Tensor::Shape out_shape_;
44
45 Tensor::Strides out_strides_;
46
47 DataType out_type_;
48};
49
50} // namespace infini::ops
51
52#endif
Definition matmul.h:9
Tensor::Strides other_strides_
Definition matmul.h:39
DataType out_type_
Definition matmul.h:47
DataType other_type_
Definition matmul.h:41
Tensor::Strides out_strides_
Definition matmul.h:45
DataType input_type_
Definition matmul.h:35
Matmul(const Tensor input, const Tensor other, Tensor out)
Definition matmul.h:11
Tensor::Strides input_strides_
Definition matmul.h:33
Tensor::Shape input_shape_
Definition matmul.h:31
Tensor::Shape other_shape_
Definition matmul.h:37
Tensor::Shape out_shape_
Definition matmul.h:43
virtual void operator()(const Tensor input, const Tensor other, Tensor out) const =0
Definition generated/include/operator.h:282
Definition generated/include/operator.h:28
infini::rt::TensorView Tensor
Definition tensor.h:8