Updated the examples

This commit is contained in:
Alejandro Saucedo 2021-02-09 22:15:07 +00:00
parent 3c486ebf72
commit 48f041d9f3
5 changed files with 8 additions and 32 deletions

View file

@ -42,14 +42,7 @@ void KomputeModelML::train(std::vector<float> yData, std::vector<float> xIData,
kp::Manager mgr;
{
std::shared_ptr<kp::Sequence> sqTensor =
mgr.sequence();
sqTensor->begin();
sqTensor->record<kp::OpTensorCreate>(params);
sqTensor->end();
sqTensor->eval();
mgr.rebuild(params);
std::shared_ptr<kp::Sequence> sq = mgr.sequence();

View file

@ -12,7 +12,7 @@ void KomputeSummatorNode::add(float value) {
// Set the new data in the local device
this->mSecondaryTensor->setData({value});
// Execute recorded sequence
if (std::shared_ptr<kp::Sequence> sq = this->mSequence.lock()) {
if (std::shared_ptr<kp::Sequence> sq = this->mSequence) {
sq->eval();
}
else {
@ -34,7 +34,7 @@ void KomputeSummatorNode::_init() {
this->mSequence = this->mManager.sequence("AdditionSeq");
// We now record the steps in the sequence
if (std::shared_ptr<kp::Sequence> sq = this->mSequence.lock())
if (std::shared_ptr<kp::Sequence> sq = this->mSequence)
{
std::string shader(R"(
@ -59,7 +59,7 @@ void KomputeSummatorNode::_init() {
{ this->mSecondaryTensor });
// Then we run the operation with both tensors
sq->record<kp::OpAlgoBase<>>(
sq->record<kp::OpAlgoBase>(
{ this->mPrimaryTensor, this->mSecondaryTensor },
std::vector<char>(shader.begin(), shader.end()));

View file

@ -50,14 +50,9 @@ void KomputeModelMLNode::train(Array yArr, Array xIArr, Array xJArr) {
{
kp::Manager mgr;
std::shared_ptr<kp::Sequence> sqTensor =
mgr.sequence();
sqTensor->begin();
sqTensor->record<kp::OpTensorCreate>(params);
sqTensor->end();
sqTensor->eval();
mgr.rebuild(params);
{
std::shared_ptr<kp::Sequence> sq = mgr.sequence();
// Record op algo base

View file

@ -55,13 +55,7 @@ void KomputeModelML::train(Array yArr, Array xIArr, Array xJArr) {
kp::Manager mgr;
{
std::shared_ptr<kp::Sequence> sqTensor =
mgr.sequence();
sqTensor->begin();
sqTensor->record<kp::OpTensorCreate>(params);
sqTensor->end();
sqTensor->eval();
mgr.rebuild(params);
std::shared_ptr<kp::Sequence> sq = mgr.sequence();

View file

@ -35,13 +35,7 @@ int main()
kp::Manager mgr;
std::shared_ptr<kp::Sequence> sqTensor =
mgr.sequence();
sqTensor->begin();
sqTensor->record<kp::OpTensorCreate>(params);
sqTensor->end();
sqTensor->eval();
mgr.rebuild(params);
std::shared_ptr<kp::Sequence> sq = mgr.sequence();