Skip to content

Commit 5b7206c

Browse files
committed
feat: add NllLoss2dForwardOutput base
1 parent 57ec7e3 commit 5b7206c

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef INFINI_OPS_BASE_NLL_LOSS2D_FORWARD_OUTPUT_H_
2+
#define INFINI_OPS_BASE_NLL_LOSS2D_FORWARD_OUTPUT_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class NllLoss2dForwardOutput : public Operator<NllLoss2dForwardOutput> {
9+
public:
10+
NllLoss2dForwardOutput(const Tensor self, const Tensor target,
11+
const int64_t reduction, const int64_t ignore_index,
12+
Tensor output, Tensor total_weight)
13+
: self_shape_{self.shape()},
14+
self_strides_{self.strides()},
15+
self_type_{self.dtype()},
16+
target_shape_{target.shape()},
17+
target_strides_{target.strides()},
18+
target_type_{target.dtype()},
19+
output_shape_{output.shape()},
20+
output_strides_{output.strides()},
21+
output_type_{output.dtype()},
22+
total_weight_shape_{total_weight.shape()},
23+
total_weight_strides_{total_weight.strides()},
24+
total_weight_type_{total_weight.dtype()},
25+
device_index_{output.device().index()} {}
26+
27+
virtual void operator()(const Tensor self, const Tensor target,
28+
const int64_t reduction, const int64_t ignore_index,
29+
Tensor output, Tensor total_weight) const = 0;
30+
31+
protected:
32+
Tensor::Shape self_shape_;
33+
Tensor::Strides self_strides_;
34+
DataType self_type_;
35+
Tensor::Shape target_shape_;
36+
Tensor::Strides target_strides_;
37+
DataType target_type_;
38+
Tensor::Shape output_shape_;
39+
Tensor::Strides output_strides_;
40+
DataType output_type_;
41+
Tensor::Shape total_weight_shape_;
42+
Tensor::Strides total_weight_strides_;
43+
DataType total_weight_type_;
44+
int device_index_{0};
45+
};
46+
47+
} // namespace infini::ops
48+
49+
#endif

0 commit comments

Comments
 (0)