#ifndef OLC_GUARD_MLOPEN_OP_KERNEL_ARGS_HPP #define OLC_GUARD_MLOPEN_OP_KERNEL_ARGS_HPP #include #include #include #include namespace online_compile { struct OpKernelArg { OpKernelArg(char val, size_t sz) : buffer(sz) { std::fill(buffer.begin(), buffer.end(), val); } template OpKernelArg(T arg) : buffer(sizeof(T)) { static_assert(std::is_trivial{} || std::is_same{}, "Only for trivial types"); *(reinterpret_cast(buffer.data())) = arg; } template OpKernelArg(T* arg) // NOLINT : buffer(sizeof(T*)) { *(reinterpret_cast(buffer.data())) = arg; is_ptr = true; } std::size_t size() const { return buffer.size(); }; boost::container::small_vector buffer; bool is_ptr = false; }; } // namespace online_compile #endif