Skip to content

Commit eb43fc2

Browse files
committed
feat: add multilabel_margin_loss_forward base
1 parent cfea02e commit eb43fc2

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#ifndef INFINI_OPS_BASE_MULTILABEL_MARGIN_LOSS_FORWARD_H_
2+
#define INFINI_OPS_BASE_MULTILABEL_MARGIN_LOSS_FORWARD_H_
3+
4+
#include "operator.h"
5+
6+
namespace infini::ops {
7+
8+
class MultilabelMarginLossForward
9+
: public Operator<MultilabelMarginLossForward> {
10+
public:
11+
MultilabelMarginLossForward(const Tensor input, const Tensor target,
12+
const int64_t reduction, Tensor output,
13+
Tensor is_target)
14+
: input_shape_{input.shape()},
15+
input_strides_{input.strides()},
16+
input_type_{input.dtype()},
17+
target_shape_{target.shape()},
18+
target_strides_{target.strides()},
19+
target_type_{target.dtype()},
20+
output_shape_{output.shape()},
21+
output_strides_{output.strides()},
22+
output_type_{output.dtype()},
23+
is_target_shape_{is_target.shape()},
24+
is_target_strides_{is_target.strides()},
25+
is_target_type_{is_target.dtype()},
26+
reduction_{reduction},
27+
device_index_{output.device().index()} {}
28+
29+
virtual void operator()(const Tensor input, const Tensor target,
30+
const int64_t reduction, Tensor output,
31+
Tensor is_target) const = 0;
32+
33+
protected:
34+
Tensor::Shape input_shape_;
35+
36+
Tensor::Strides input_strides_;
37+
38+
DataType input_type_;
39+
40+
Tensor::Shape target_shape_;
41+
42+
Tensor::Strides target_strides_;
43+
44+
DataType target_type_;
45+
46+
Tensor::Shape output_shape_;
47+
48+
Tensor::Strides output_strides_;
49+
50+
DataType output_type_;
51+
52+
Tensor::Shape is_target_shape_;
53+
54+
Tensor::Strides is_target_strides_;
55+
56+
DataType is_target_type_;
57+
58+
int64_t reduction_{};
59+
60+
int device_index_{0};
61+
};
62+
63+
} // namespace infini::ops
64+
65+
#endif

0 commit comments

Comments
 (0)