24 using ImageView =
decltype(xt::view(unused_, std::size_t{}, std::size_t{}));
25 using KernelView =
decltype(xt::view(unused_, std::size_t{}, std::size_t{}, xt::xrange(0l, 0l), xt::xrange(0l, 0l)));
31 Tensor(std::initializer_list<std::int64_t>
dims);
36 explicit Tensor(std::int64_t value);
41 explicit Tensor(
float value);
46 explicit Tensor(
const std::vector<std::int64_t> &
dims);
56 explicit Tensor(const ::onnx::TensorProto &tensor);
62 explicit Tensor(const ::onnx::ValueInfoProto &value_info,
const std::string &name);
65 [[nodiscard]]
const xt::xarray<Expression> &
values()
const {
return values_; }
67 [[nodiscard]] std::size_t
size()
const {
return values_.size(); }
69 [[nodiscard]] std::size_t
ndim()
const {
return values_.dimension(); }
71 [[nodiscard]] std::vector<std::int64_t>
dims()
const;
81 [[nodiscard]] std::int64_t
dim(std::size_t i)
const;
163 Tensor &
Slice(
const std::vector<std::int64_t> &starts,
const std::vector<std::int64_t> &ends,
164 const std::vector<std::int64_t> &axes = {},
const std::vector<std::int64_t> &steps = {});
203 Tensor Concat(
const std::vector<Tensor> &rhs, std::int64_t axis);
242 [[nodiscard]]
Tensor Convolution(
const Tensor &w,
const std::vector<std::int64_t> &dilations, std::int64_t group,
243 const std::vector<std::int64_t> &kernel_shape,
const std::vector<std::int64_t> &pads,
244 const std::vector<std::int64_t> &strides)
const;
263 [[nodiscard]] xt::xarray<Expression>
Convolution(
const ImageView &image,
const KernelView &kernel,
264 const std::vector<std::size_t> &new_shape,
265 const std::vector<std::int64_t> &dilations, std::int64_t group,
266 const std::vector<std::int64_t> &pads,
267 const std::vector<std::int64_t> &strides)
const;
268 const Expression &Max()
const;
275 [[nodiscard]]
Tensor Pad(
const std::vector<std::int64_t> &pads)
const;
277 [[nodiscard]]
Tensor Squeeze()
const;
278 [[nodiscard]]
Tensor Squeeze(std::vector<std::int64_t> axes)
const;
280 template <IsAnyOf<
int, std::
int64_t, std::
size_t>... Dims>
281 Expression &operator()(Dims...
dims) {
284 template <IsAnyOf<
int, std::
int64_t, std::
size_t>... Dims>
285 const Expression &operator()(Dims...
dims)
const {
288 Expression &operator()(std::initializer_list<std::int64_t>
dims);
289 const Expression &operator()(std::initializer_list<std::int64_t>
dims)
const;
291 std::vector<Formula> operator<(
const Tensor &rhs)
const;
292 std::vector<Formula> operator<=(
const Tensor &rhs)
const;
293 std::vector<Formula> operator>(
const Tensor &rhs)
const;
294 std::vector<Formula> operator>=(
const Tensor &rhs)
const;
295 std::vector<Formula> operator==(
const Tensor &rhs)
const;
296 std::vector<Formula> operator!=(
const Tensor &rhs)
const;
298 explicit operator std::vector<std::int64_t>()
const;
299 explicit operator std::vector<double>()
const;
300 explicit operator std::vector<std::size_t>()
const;
302 Expression &operator[](
int index);
303 const Expression &operator[](
int index)
const;
304 Expression &operator[](std::size_t index);
305 const Expression &operator[](std::size_t index)
const;
307 auto begin() {
return values_.begin(); }
308 auto end() {
return values_.end(); }
309 [[nodiscard]]
auto begin()
const {
return values_.begin(); }
310 [[nodiscard]]
auto end()
const {
return values_.end(); }
311 [[nodiscard]]
auto cbegin()
const {
return values_.cbegin(); }
312 [[nodiscard]]
auto cend()
const {
return values_.cend(); }
314 ARITHMETIC_OPERATORS(
Tensor);
315 GENERIC_ARITHMETIC_OPERATORS(
Tensor, Expression &);
323 [[nodiscard]] std::size_t
ComputeOffset(std::initializer_list<std::int64_t>
dims)
const;
Tensor Convolution(const Tensor &w, const std::vector< std::int64_t > &dilations, std::int64_t group, const std::vector< std::int64_t > &kernel_shape, const std::vector< std::int64_t > &pads, const std::vector< std::int64_t > &strides) const
Convolution of two tensors.