// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include <iostream>
#include <sstream>
template <typename T>
inline void MakeStringInternal(std::ostringstream& ss, const T& t) noexcept {
ss << t;
}
template <>
inline void MakeStringInternal(std::ostringstream& ss, const std::vector<int64_t>& t) noexcept {
for (auto it = t.begin(); it != t.end(); ++it) {
ss << *it << "x";
}
}
template <typename T, typename... Args>
void MakeStringInternal(std::ostringstream& ss, const T& t, const Args&... args) noexcept {
MakeStringInternal(ss, t);
MakeStringInternal(ss, args...);
}
template <typename... Args>
std::string MakeString(const Args&... args) {
std::ostringstream ss;
MakeStringInternal(ss, args...);
return std::string(ss.str());
}
inline int64_t Size(const std::vector<int64_t>& shape) {
int64_t res = 1;
for (auto it = shape.begin(); it != shape.end(); ++it) {
res *= *it;
}
return res;
}microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
ocos/utils.h
38lines · modepreview