Forked from
Eclipse Projects / aidge / aidge_backend_cpu
255 commits behind, 14 commits ahead of the upstream repository.
-
Noam Zerah authoredNoam Zerah authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Test_ScalingMeta.cpp 2.88 KiB
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#include <catch2/catch_test_macros.hpp>
#include <cmath>
#include <cstdlib>
#include <memory>
#include "aidge/utils/TensorUtils.hpp"
#include "aidge/backend/cpu/operator/ConvImpl.hpp"
#include "aidge/backend/cpu/operator/PadImpl.hpp"
#include "aidge/data/Tensor.hpp"
#include "aidge/operator/Conv.hpp"
#include "aidge/operator/MetaOperator.hpp"
#include "aidge/operator/MetaOperatorDefs.hpp"
#include "aidge/operator/Pad.hpp"
#include "aidge/operator/Pop.hpp"
#include "aidge/scheduler/SequentialScheduler.hpp"
#include "aidge/scheduler/ParallelScheduler.hpp"
using namespace Aidge;
TEST_CASE("ScalingNodeMeta", "[ScalingMeta][CPU]") {
/*SECTION("Scaling MetaOperator")
{
std::shared_ptr<Tensor> t0 = std::make_shared<Tensor>(
Array2D<float, 3, 3>{{{45, 72, 2},
{84.15, 144.45, 0.01484},
{0.62132, 17.67132, 212.132}}});
auto scal = ScalingMeta(2,8,false);
auto scalop = std::static_pointer_cast<OperatorTensor>(scal->getOperator());
t0->setBackend("cpu");
scalop->associateInput(0,t0);
scalop->setBackend("cpu");
scalop->forwardDims();
scalop->forward();
//auto sf = scalop -> getInput(1);
auto out0 = scalop->getOutput(0);
auto in0 = scalop->getInput(0);
auto in1 = scalop->getInput(1);
std::cout << "in0 is: ";
in0->print();
std::cout << "in1 is: ";
in1->print();
std::cout << "output is: " ;
out0->print();
}*/
SECTION("MulPTQ")
{
std::shared_ptr<Tensor> t0 = std::make_shared<Tensor>(
Array2D<float, 3, 3>{{{45, 72, 2},
{84.15, 144.45, 0.01484},
{0.62132, 17.67132, 212.132}}});
auto scal = MulPTQ(2.001);
auto scalop = std::static_pointer_cast<OperatorTensor>(scal->getOperator());
t0->setBackend("cpu");
scal->getOperator()->associateInput(0,t0);
auto g = getConnectedGraphView(scal);
g->setDataType(DataType::Float32);
g->setBackend("cpu");
auto scheduler = SequentialScheduler(g);
scheduler.forward();
auto out0 = scalop->getOutput(0);
auto in0 = scalop->getInput(0);
auto in1 = scalop->getInput(1);
std::cout << "in0 is: ";
in0->print();
std::cout << "in1 is: ";
in1->print();
std::cout << "output is: " ;
out0->print();
}
}