From 5f62c5bec65241bd417c9f37f5d50b28120f2b7d Mon Sep 17 00:00:00 2001 From: Jiacheng Huang Date: Wed, 13 May 2026 14:39:27 +0800 Subject: [PATCH 1/2] feat: add `normal` base --- src/base/normal.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/base/normal.h diff --git a/src/base/normal.h b/src/base/normal.h new file mode 100644 index 000000000..a156e0c30 --- /dev/null +++ b/src/base/normal.h @@ -0,0 +1,64 @@ +#ifndef INFINI_OPS_BASE_NORMAL_H_ +#define INFINI_OPS_BASE_NORMAL_H_ + +#include "operator.h" + +namespace infini::ops { + +class Normal : public Operator { + public: + Normal(const Tensor mean, const double std, Tensor out) + : mean_shape_{mean.shape()}, + mean_strides_{mean.strides()}, + mean_type_{mean.dtype()}, + out_shape_{out.shape()}, + out_strides_{out.strides()}, + out_type_{out.dtype()}, + std_{std}, + device_index_{out.device().index()} {} + + Normal(const Tensor mean, const Tensor std, Tensor out) + : mean_shape_{mean.shape()}, + mean_strides_{mean.strides()}, + mean_type_{mean.dtype()}, + out_shape_{out.shape()}, + out_strides_{out.strides()}, + out_type_{out.dtype()}, + std_shape_{std.shape()}, + std_strides_{std.strides()}, + std_type_{std.dtype()}, + device_index_{out.device().index()} {} + + virtual void operator()(const Tensor mean, const double std, + Tensor out) const = 0; + + virtual void operator()(const Tensor mean, const Tensor std, + Tensor out) const = 0; + + protected: + Tensor::Shape mean_shape_; + + Tensor::Strides mean_strides_; + + DataType mean_type_; + + Tensor::Shape out_shape_; + + Tensor::Strides out_strides_; + + DataType out_type_; + + double std_{}; + + Tensor::Shape std_shape_; + + Tensor::Strides std_strides_; + + DataType std_type_; + + int device_index_{0}; +}; + +} // namespace infini::ops + +#endif \ No newline at end of file From a79f8fee63348dc83e0006a7b5131411dc1f2533 Mon Sep 17 00:00:00 2001 From: Jiacheng Huang Date: Mon, 18 May 2026 19:51:40 +0800 Subject: [PATCH 2/2] fix: add trailing newline to base header --- src/base/normal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/normal.h b/src/base/normal.h index a156e0c30..c904ab002 100644 --- a/src/base/normal.h +++ b/src/base/normal.h @@ -61,4 +61,4 @@ class Normal : public Operator { } // namespace infini::ops -#endif \ No newline at end of file +#endif