From 8a7d1b1e2f10e1c19fc94dff6219e6ffb19453d6 Mon Sep 17 00:00:00 2001 From: Jiacheng Huang Date: Wed, 13 May 2026 13:45:35 +0800 Subject: [PATCH] feat: add `sgn` base Rebased onto feat/torch-operator-bases with only src/base/sgn.h. --- src/base/sgn.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/base/sgn.h diff --git a/src/base/sgn.h b/src/base/sgn.h new file mode 100644 index 000000000..499ce2a6c --- /dev/null +++ b/src/base/sgn.h @@ -0,0 +1,39 @@ +#ifndef INFINI_OPS_BASE_SGN_H_ +#define INFINI_OPS_BASE_SGN_H_ + +#include "operator.h" + +namespace infini::ops { + +class Sgn : public Operator { + public: + Sgn(const Tensor input, Tensor out) + : input_shape_{input.shape()}, + input_strides_{input.strides()}, + input_type_{input.dtype()}, + out_shape_{out.shape()}, + out_strides_{out.strides()}, + out_type_{out.dtype()}, + device_index_{out.device().index()} {} + + virtual void operator()(const Tensor input, Tensor out) const = 0; + + protected: + Tensor::Shape input_shape_; + + Tensor::Strides input_strides_; + + DataType input_type_; + + Tensor::Shape out_shape_; + + Tensor::Strides out_strides_; + + DataType out_type_; + + int device_index_{0}; +}; + +} // namespace infini::ops + +#endif