diff --git a/src/base/nuclear_norm.h b/src/base/nuclear_norm.h new file mode 100644 index 000000000..e53147708 --- /dev/null +++ b/src/base/nuclear_norm.h @@ -0,0 +1,60 @@ +#ifndef INFINI_OPS_BASE_NUCLEAR_NORM_H_ +#define INFINI_OPS_BASE_NUCLEAR_NORM_H_ + +#include "operator.h" + +namespace infini::ops { + +class NuclearNorm : public Operator { + public: + NuclearNorm(const Tensor input, const bool keepdim, 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()}, + keepdim_{keepdim}, + device_index_{out.device().index()} {} + + NuclearNorm(const Tensor input, const std::vector dim, + const bool keepdim, 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()}, + keepdim_{keepdim}, + dim_{dim}, + device_index_{out.device().index()} {} + + virtual void operator()(const Tensor input, const bool keepdim, + Tensor out) const = 0; + + virtual void operator()(const Tensor input, const std::vector dim, + const bool keepdim, 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_; + + bool keepdim_{}; + + std::vector dim_{}; + + int device_index_{0}; +}; + +} // namespace infini::ops + +#endif \ No newline at end of file