Skip to content

Commit 3117d93

Browse files
committed
Add smooth_l1_loss operator
1 parent 297695f commit 3117d93

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

include/infiniop.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include "infiniop/ops/dequantize_awq.h"
1111
#include "infiniop/ops/gelu.h"
1212
#include "infiniop/ops/gemm.h"
13+
#include "infiniop/ops/hypot.h"
14+
#include "infiniop/ops/index_add.h"
15+
#include "infiniop/ops/index_copy.h"
1316
#include "infiniop/ops/layer_norm.h"
1417
#include "infiniop/ops/logsoftmax.h"
1518
#include "infiniop/ops/lp_norm.h"
@@ -22,11 +25,13 @@
2225
#include "infiniop/ops/rope.h"
2326
#include "infiniop/ops/sigmoid.h"
2427
#include "infiniop/ops/silu.h"
28+
#include "infiniop/ops/smooth_l1_loss.h"
2529
#include "infiniop/ops/softmax.h"
2630
#include "infiniop/ops/softplus.h"
2731
#include "infiniop/ops/sub.h"
2832
#include "infiniop/ops/swiglu.h"
2933
#include "infiniop/ops/tanh.h"
34+
#include "infiniop/ops/take.h"
3035
#include "infiniop/ops/topkrouter.h"
3136
#include "infiniop/ops/topksoftmax.h"
3237
#include "infiniop/ops/zeros.h"

python/infinicore/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
from infinicore.ops.mul import mul
4646
from infinicore.ops.narrow import narrow
4747
from infinicore.ops.rearrange import rearrange
48+
from infinicore.ops.hypot import hypot
49+
from infinicore.ops.index_add import index_add
50+
from infinicore.ops.index_copy import index_copy
51+
from infinicore.ops.take import take
4852
from infinicore.tensor import (
4953
Tensor,
5054
empty,
@@ -111,6 +115,10 @@
111115
"from_list",
112116
"from_numpy",
113117
"from_torch",
118+
"hypot",
119+
"index_copy",
120+
"index_add",
121+
"take",
114122
"ones",
115123
"strided_empty",
116124
"strided_from_blob",

python/infinicore/nn/functional/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
from .rope import RopeAlgo, rope
77
from .silu import silu
88
from .swiglu import swiglu
9-
9+
from .smooth_l1_loss import smooth_l1_loss
1010
__all__ = [
1111
"causal_softmax",
1212
"random_sample",
1313
"rms_norm",
1414
"silu",
15+
"smooth_l1_loss",
1516
"swiglu",
1617
"linear",
1718
"embedding",

src/infinicore/pybind11/ops.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#include "ops/attention.hpp"
77
#include "ops/causal_softmax.hpp"
88
#include "ops/embedding.hpp"
9+
#include "ops/hypot.hpp"
10+
#include "ops/take.hpp"
11+
#include "ops/index_copy.hpp"
12+
#include "ops/index_add.hpp"
13+
#include "ops/smooth_l1_loss.hpp"
914
#include "ops/linear.hpp"
1015
#include "ops/matmul.hpp"
1116
#include "ops/mul.hpp"
@@ -28,6 +33,11 @@ inline void bind(py::module &m) {
2833
bind_linear(m);
2934
bind_matmul(m);
3035
bind_mul(m);
36+
bind_hypot(m);
37+
bind_take(m);
38+
bind_index_copy(m);
39+
bind_index_add(m);
40+
bind_smooth_l1_loss(m);
3141
bind_rearrange(m);
3242
bind_rms_norm(m);
3343
bind_silu(m);

src/infiniop/ops/smooth_l1_loss/cuda/kernel.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef __SMOOTH_L1_LOSS_CUDA_CUH__
22
#define __SMOOTH_L1_LOSS_CUDA_CUH__
33

4-
#include <cuda_runtime.h>
54
#if defined(__MACA__) || defined(__MACACC__)
65
#include <maca_fp16.h>
76
#include <maca_bfloat16.h>
87
using nv_bfloat162 = __maca_bfloat162;
98
#else
9+
#include <cuda_runtime.h>
1010
#include <cuda_fp16.h>
1111
#include <cuda_bf16.h>
1212
#endif

0 commit comments

Comments
 (0)