voice_audio_multi/include/engine/framework/neon/tensor.h
Fabio c36510c21e
Some checks failed
Linux Build / Linux cpu (push) Has been cancelled
Linux Build / Linux cpu-clang (push) Has been cancelled
Linux Build / Linux vulkan (push) Has been cancelled
mac-build / macOS CPU (push) Has been cancelled
Nix Build / Nix (cpu) (push) Has been cancelled
Nix Build / Nix (vulkan) (push) Has been cancelled
windows-build / Windows CPU (push) Has been cancelled
Initial import: audio.cpp with Orange Pi documentation
2026-11-04 19:05:22 +01:00

43 lines
1.1 KiB
C++

#pragma once
#include <array>
#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include <vector>
namespace engine::neon {
enum class Layout { ChannelFirst, FrameMajor };
enum class DataType { Float32, Int32 };
// Dimensions remain logical [channels, frames] or [channels, height, width].
// FrameMajor stores a sequence as [frames, channels].
struct Shape {
std::array<int, 4> dimensions{};
size_t rank = 0;
Layout layout = Layout::ChannelFirst;
Shape(std::initializer_list<int> dimensions, Layout layout = Layout::ChannelFirst);
size_t elements() const;
bool operator==(const Shape &other) const noexcept;
};
struct TensorView {
const float *data;
size_t size;
Shape shape;
const int32_t *indices = nullptr;
DataType type = DataType::Float32;
TensorView(const std::vector<float> &values, Shape shape);
TensorView(const float *data, size_t size, Shape shape);
TensorView(const int32_t *indices, size_t size, Shape shape);
};
struct Tensor {
Shape shape;
std::vector<float> values;
};
} // namespace engine::neon