Migrate model class to Tensor

This commit is contained in:
2025-11-22 22:40:38 +01:00
parent ca44ea4436
commit 51bcee01ab
11 changed files with 207 additions and 254 deletions

View File

@@ -1,11 +1,21 @@
#pragma once
#include <format>
#include <vector>
namespace CUDANet {
typedef std::vector<size_t> Shape;
std::string format_shape(const Shape& shape) {
std::string result;
for (size_t i = 0; i < shape.size(); ++i) {
if (i > 0) result += ", ";
result += std::to_string(shape[i]);
}
return result;
}
class InvalidShapeException : public std::runtime_error {
public:
InvalidShapeException(
@@ -35,16 +45,6 @@ class InvalidShapeException : public std::runtime_error {
format_shape(shape_b)
)
) {}
private:
static std::string format_shape(const Shape& shape) {
std::string result;
for (size_t i = 0; i < shape.size(); ++i) {
if (i > 0) result += ", ";
result += std::to_string(shape[i]);
}
return result;
}
};
} // namespace CUDANet