mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-11-08 13:12:09 +01:00
Implemented tensor_vec_mult, also swapped some parameters in MLPPTensor to match the expected order.
This commit is contained in:
parent
197b59b752
commit
6a7448b278
@ -240,7 +240,7 @@ void MLPPTensor3::shape_set(const Size3i &p_size) {
|
||||
_size = p_size;
|
||||
}
|
||||
|
||||
Vector<real_t> MLPPTensor3::row_get_vector(int p_index_y, int p_index_z) const {
|
||||
Vector<real_t> MLPPTensor3::row_get_vector(int p_index_z, int p_index_y) const {
|
||||
ERR_FAIL_INDEX_V(p_index_y, _size.y, Vector<real_t>());
|
||||
ERR_FAIL_INDEX_V(p_index_z, _size.z, Vector<real_t>());
|
||||
|
||||
@ -263,7 +263,7 @@ Vector<real_t> MLPPTensor3::row_get_vector(int p_index_y, int p_index_z) const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PoolRealArray MLPPTensor3::row_get_pool_vector(int p_index_y, int p_index_z) const {
|
||||
PoolRealArray MLPPTensor3::row_get_pool_vector(int p_index_z, int p_index_y) const {
|
||||
ERR_FAIL_INDEX_V(p_index_y, _size.y, PoolRealArray());
|
||||
ERR_FAIL_INDEX_V(p_index_z, _size.z, PoolRealArray());
|
||||
|
||||
@ -287,7 +287,7 @@ PoolRealArray MLPPTensor3::row_get_pool_vector(int p_index_y, int p_index_z) con
|
||||
return ret;
|
||||
}
|
||||
|
||||
Ref<MLPPVector> MLPPTensor3::row_get_mlpp_vector(int p_index_y, int p_index_z) const {
|
||||
Ref<MLPPVector> MLPPTensor3::row_get_mlpp_vector(int p_index_z, int p_index_y) const {
|
||||
ERR_FAIL_INDEX_V(p_index_y, _size.y, Ref<MLPPVector>());
|
||||
ERR_FAIL_INDEX_V(p_index_z, _size.z, Ref<MLPPVector>());
|
||||
|
||||
@ -311,7 +311,7 @@ Ref<MLPPVector> MLPPTensor3::row_get_mlpp_vector(int p_index_y, int p_index_z) c
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MLPPTensor3::row_get_into_mlpp_vector(int p_index_y, int p_index_z, Ref<MLPPVector> target) const {
|
||||
void MLPPTensor3::row_get_into_mlpp_vector(int p_index_z, int p_index_y, Ref<MLPPVector> target) const {
|
||||
ERR_FAIL_COND(!target.is_valid());
|
||||
ERR_FAIL_INDEX(p_index_y, _size.y);
|
||||
ERR_FAIL_INDEX(p_index_z, _size.z);
|
||||
@ -1841,21 +1841,25 @@ real_t MLPPTensor3::norm_2(std::vector<std::vector<std::vector<real_t>>> A) {
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
std::vector<std::vector<real_t>> MLPPTensor3::tensor_vec_mult(std::vector<std::vector<std::vector<real_t>>> A, std::vector<real_t> b) {
|
||||
std::vector<std::vector<real_t>> C;
|
||||
C.resize(A.size());
|
||||
for (uint32_t i = 0; i < C.size(); i++) {
|
||||
C[i].resize(A[0].size());
|
||||
}
|
||||
for (uint32_t i = 0; i < C.size(); i++) {
|
||||
for (uint32_t j = 0; j < C[i].size(); j++) {
|
||||
C[i][j] = dot(A[i][j], b);
|
||||
Ref<MLPPMatrix> MLPPTensor3::tensor_vec_mult(const Ref<MLPPVector> &b) {
|
||||
Ref<MLPPMatrix> C;
|
||||
C.instance();
|
||||
C->resize(Size2i(_size.y, _size.z));
|
||||
|
||||
Ref<MLPPVector> row_tmp;
|
||||
row_tmp.instance();
|
||||
row_tmp->resize(_size.x);
|
||||
|
||||
for (int i = 0; i < _size.z; i++) {
|
||||
for (int j = 0; j < _size.y; j++) {
|
||||
row_get_into_mlpp_vector(i, j, row_tmp);
|
||||
|
||||
C->element_set(i, j, row_tmp->dot(b));
|
||||
}
|
||||
}
|
||||
|
||||
return C;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// Bad implementation. Change this later.
|
||||
|
@ -14,13 +14,13 @@
|
||||
|
||||
#include "core/object/resource.h"
|
||||
|
||||
#else
|
||||
#else
|
||||
|
||||
#include "core/containers/vector.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/math_funcs.h"
|
||||
#include "core/pool_arrays.h"
|
||||
#include "core/containers/vector.h"
|
||||
#include "core/os/memory.h"
|
||||
#include "core/pool_arrays.h"
|
||||
|
||||
#include "gen/resource.h"
|
||||
|
||||
@ -121,10 +121,10 @@ public:
|
||||
_data[p_index_y * _size.x + p_index_x + _size.x * _size.y * p_index_z] = p_val;
|
||||
}
|
||||
|
||||
Vector<real_t> row_get_vector(int p_index_y, int p_index_z) const;
|
||||
PoolRealArray row_get_pool_vector(int p_index_y, int p_index_z) const;
|
||||
Ref<MLPPVector> row_get_mlpp_vector(int p_index_y, int p_index_z) const;
|
||||
void row_get_into_mlpp_vector(int p_index_y, int p_index_z, Ref<MLPPVector> target) const;
|
||||
Vector<real_t> row_get_vector(int p_index_z, int p_index_y) const;
|
||||
PoolRealArray row_get_pool_vector(int p_index_z, int p_index_y) const;
|
||||
Ref<MLPPVector> row_get_mlpp_vector(int p_index_z, int p_index_y) const;
|
||||
void row_get_into_mlpp_vector(int p_index_z, int p_index_y, Ref<MLPPVector> target) const;
|
||||
|
||||
void row_set_vector(int p_index_y, int p_index_z, const Vector<real_t> &p_row);
|
||||
void row_set_pool_vector(int p_index_y, int p_index_z, const PoolRealArray &p_row);
|
||||
@ -244,7 +244,7 @@ public:
|
||||
|
||||
//real_t norm_2(std::vector<std::vector<std::vector<real_t>>> A);
|
||||
|
||||
//std::vector<std::vector<real_t>> tensor_vec_mult(std::vector<std::vector<std::vector<real_t>>> A, std::vector<real_t> b);
|
||||
Ref<MLPPMatrix> tensor_vec_mult(const Ref<MLPPVector> &b);
|
||||
//std::vector<std::vector<std::vector<real_t>>> vector_wise_tensor_product(std::vector<std::vector<std::vector<real_t>>> A, std::vector<std::vector<real_t>> B);
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user