geopm 3.1.1.dev410+g40bf96ed
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
TensorMath.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 - 2024 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef TENSORMATH_HPP_INCLUDE
7#define TENSORMATH_HPP_INCLUDE
8
9#include <memory>
10#include <vector>
11
12namespace geopm
13{
14 class TensorOneD;
15 class TensorTwoD;
16
21 {
22 public:
25 static std::shared_ptr<TensorMath> make_shared();
26
27 virtual ~TensorMath() = default;
28
36 virtual TensorOneD add(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const = 0;
44 virtual TensorOneD subtract(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const = 0;
52 virtual double inner_product(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const = 0;
54
55 virtual TensorOneD sigmoid(const TensorOneD &tensor) const = 0;
56
65 virtual TensorOneD multiply(const TensorTwoD &, const TensorOneD &) const = 0;
66 };
67
69 {
70 public:
71 TensorMathImp() = default;
72 virtual ~TensorMathImp() = default;
73 TensorOneD add(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const override;
74 TensorOneD subtract(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const override;
75 double inner_product(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const override;
76 TensorOneD sigmoid(const TensorOneD &tensor) const override;
77 TensorOneD multiply(const TensorTwoD &, const TensorOneD &) const override;
78 };
79}
80#endif /* TENSORMATH_HPP_INCLUDE */
Class to perform operations on 1D and 2D Tensors, aka vectors and matrices, suitable for use in feed-...
Definition TensorMath.hpp:21
static std::shared_ptr< TensorMath > make_shared()
Returns a shared_ptr to a concrete object constructed using the underlying implementation.
Definition TensorMath.cpp:23
virtual double inner_product(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const =0
Multiply two 1D tensors, element-wise, and sum the result.
virtual TensorOneD subtract(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const =0
Subtract two 1D tensors of the same length, element-wise.
virtual TensorOneD multiply(const TensorTwoD &, const TensorOneD &) const =0
Multiply a 2D tensor by a 1D tensor.
virtual ~TensorMath()=default
virtual TensorOneD sigmoid(const TensorOneD &tensor) const =0
Compute logistic sigmoid function of 1D Tensor.
virtual TensorOneD add(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const =0
Add two 1D tensors of the same length, element-wise.
Definition TensorMath.hpp:69
double inner_product(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const override
Multiply two 1D tensors, element-wise, and sum the result.
Definition TensorMath.cpp:68
TensorOneD subtract(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const override
Subtract two 1D tensors of the same length, element-wise.
Definition TensorMath.cpp:48
virtual ~TensorMathImp()=default
TensorOneD add(const TensorOneD &tensor_a, const TensorOneD &tensor_b) const override
Add two 1D tensors of the same length, element-wise.
Definition TensorMath.cpp:28
TensorOneD sigmoid(const TensorOneD &tensor) const override
Compute logistic sigmoid function of 1D Tensor.
Definition TensorMath.cpp:83
TensorOneD multiply(const TensorTwoD &, const TensorOneD &) const override
Multiply a 2D tensor by a 1D tensor.
Definition TensorMath.cpp:101
Class to store and perform operations on 1D Tensors, aka vectors, suitable for use in feed-forward ne...
Definition TensorOneD.hpp:21
Class to manage data and operations related to 2D Tensors required for neural net inference.
Definition TensorTwoD.hpp:22
Definition Accumulator.cpp:12