From 6c3ddb1ec0ff8391179f8595dba6804e7d45fffb Mon Sep 17 00:00:00 2001 From: Jiacheng Huang Date: Wed, 13 May 2026 14:39:15 +0800 Subject: [PATCH 1/2] feat: add `nonzero_static` base --- src/base/nonzero_static.h | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/base/nonzero_static.h diff --git a/src/base/nonzero_static.h b/src/base/nonzero_static.h new file mode 100644 index 000000000..3ff7fdb31 --- /dev/null +++ b/src/base/nonzero_static.h @@ -0,0 +1,47 @@ +#ifndef INFINI_OPS_BASE_NONZERO_STATIC_H_ +#define INFINI_OPS_BASE_NONZERO_STATIC_H_ + +#include "operator.h" + +namespace infini::ops { + +class NonzeroStatic : public Operator { + public: + NonzeroStatic(const Tensor input, const int64_t size, + const int64_t fill_value, 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()}, + size_{size}, + fill_value_{fill_value}, + device_index_{out.device().index()} {} + + virtual void operator()(const Tensor input, const int64_t size, + const int64_t fill_value, 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_; + + int64_t size_{}; + + int64_t fill_value_{}; + + int device_index_{0}; +}; + +} // namespace infini::ops + +#endif \ No newline at end of file From b139df23310da43cd0606ae7fa17db32c261b282 Mon Sep 17 00:00:00 2001 From: Jiacheng Huang Date: Mon, 18 May 2026 19:51:55 +0800 Subject: [PATCH 2/2] fix: add trailing newline to base header --- src/base/nonzero_static.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/nonzero_static.h b/src/base/nonzero_static.h index 3ff7fdb31..8aa0601ba 100644 --- a/src/base/nonzero_static.h +++ b/src/base/nonzero_static.h @@ -44,4 +44,4 @@ class NonzeroStatic : public Operator { } // namespace infini::ops -#endif \ No newline at end of file +#endif