Added .clang-format file and formatted everything
Signed-off-by: Fabian Sauter <sauter.fabian@mailbox.org>
This commit is contained in:
parent
f731f2e55c
commit
24cd307042
47 changed files with 5157 additions and 4354 deletions
43
examples/android/android-simple/app/src/main/cpp/KomputeModelML.cpp
Executable file → Normal file
43
examples/android/android-simple/app/src/main/cpp/KomputeModelML.cpp
Executable file → Normal file
|
|
@ -1,15 +1,15 @@
|
|||
|
||||
#include "KomputeModelML.hpp"
|
||||
|
||||
KomputeModelML::KomputeModelML() {
|
||||
KomputeModelML::KomputeModelML() {}
|
||||
|
||||
}
|
||||
KomputeModelML::~KomputeModelML() {}
|
||||
|
||||
KomputeModelML::~KomputeModelML() {
|
||||
|
||||
}
|
||||
|
||||
void KomputeModelML::train(std::vector<float> yData, std::vector<float> xIData, std::vector<float> xJData) {
|
||||
void
|
||||
KomputeModelML::train(std::vector<float> yData,
|
||||
std::vector<float> xIData,
|
||||
std::vector<float> xJData)
|
||||
{
|
||||
|
||||
std::vector<float> zerosData;
|
||||
|
||||
|
|
@ -42,17 +42,19 @@ void KomputeModelML::train(std::vector<float> yData, std::vector<float> xIData,
|
|||
bIn, bOut, lOut };
|
||||
|
||||
std::vector<uint32_t> spirv = std::vector<uint32_t>(
|
||||
(uint32_t*)kp::shader_data::shaders_glsl_logisticregression_comp_spv,
|
||||
(uint32_t*)(kp::shader_data::shaders_glsl_logisticregression_comp_spv +
|
||||
kp::shader_data::shaders_glsl_logisticregression_comp_spv_len));
|
||||
|
||||
(uint32_t*)kp::shader_data::shaders_glsl_logisticregression_comp_spv,
|
||||
(uint32_t*)(kp::shader_data::
|
||||
shaders_glsl_logisticregression_comp_spv +
|
||||
kp::shader_data::
|
||||
shaders_glsl_logisticregression_comp_spv_len));
|
||||
|
||||
std::shared_ptr<kp::Algorithm> algorithm = mgr.algorithm(
|
||||
params, spirv, kp::Workgroup({ 5 }), std::vector<float>({ 5.0 }));
|
||||
params, spirv, kp::Workgroup({ 5 }), std::vector<float>({ 5.0 }));
|
||||
|
||||
mgr.sequence()->eval<kp::OpTensorSyncDevice>(params);
|
||||
|
||||
std::shared_ptr<kp::Sequence> sq = mgr.sequence()
|
||||
std::shared_ptr<kp::Sequence> sq =
|
||||
mgr.sequence()
|
||||
->record<kp::OpTensorSyncDevice>({ wIn, bIn })
|
||||
->record<kp::OpAlgoDispatch>(algorithm)
|
||||
->record<kp::OpTensorSyncLocal>({ wOutI, wOutJ, bOut, lOut });
|
||||
|
|
@ -79,7 +81,9 @@ void KomputeModelML::train(std::vector<float> yData, std::vector<float> xIData,
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<float> KomputeModelML::predict(std::vector<float> xI, std::vector<float> xJ) {
|
||||
std::vector<float>
|
||||
KomputeModelML::predict(std::vector<float> xI, std::vector<float> xJ)
|
||||
{
|
||||
|
||||
KP_LOG_INFO("Running prediction inference");
|
||||
|
||||
|
|
@ -93,9 +97,8 @@ std::vector<float> KomputeModelML::predict(std::vector<float> xI, std::vector<fl
|
|||
for (size_t i = 0; i < xI.size(); i++) {
|
||||
float xIVal = xI[i];
|
||||
float xJVal = xJ[i];
|
||||
float result = (xIVal * this->mWeights[0]
|
||||
+ xJVal * this->mWeights[1]
|
||||
+ this->mBias[0]);
|
||||
float result = (xIVal * this->mWeights[0] + xJVal * this->mWeights[1] +
|
||||
this->mBias[0]);
|
||||
|
||||
// Instead of using sigmoid we'll just return full numbers
|
||||
float var = result > 0 ? 1 : 0;
|
||||
|
|
@ -107,13 +110,15 @@ std::vector<float> KomputeModelML::predict(std::vector<float> xI, std::vector<fl
|
|||
return retVector;
|
||||
}
|
||||
|
||||
std::vector<float> KomputeModelML::get_params() {
|
||||
std::vector<float>
|
||||
KomputeModelML::get_params()
|
||||
{
|
||||
|
||||
KP_LOG_INFO("Displaying results");
|
||||
|
||||
std::vector<float> retVector;
|
||||
|
||||
if(this->mWeights.size() + this->mBias.size() == 0) {
|
||||
if (this->mWeights.size() + this->mBias.size() == 0) {
|
||||
return retVector;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue