#pragma once #include "op.h" namespace ctranslate2 { namespace ops { class Min : public BinaryOp { public: void operator()(const StorageView& a, const StorageView& b, StorageView& c) const override; private: template void compute(const StorageView& a, const StorageView& b, StorageView& c) const { c.resize_as(a); if (b.is_scalar()) { primitives::min(b.data()[0], a.data(), c.data(), c.size()); } else { primitives::min(a.data(), b.data(), c.data(), c.size()); } } }; class Max : public BinaryOp { public: void operator()(const StorageView& a, const StorageView& b, StorageView& c) const override; private: template void compute(const StorageView& a, const StorageView& b, StorageView& c) const { c.resize_as(a); if (b.is_scalar()) { primitives::max(b.data()[0], a.data(), c.data(), c.size()); } else { primitives::max(a.data(), b.data(), c.data(), c.size()); } } }; } }