Commit 92b3ea6e authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh

Fixed SLICE/INSERT implementation inside TALSH node executor

to enable registered spaces/subspaces.
parent a407800a
......@@ -511,7 +511,11 @@ void create_exatn_py_module(py::module &m) {
.def("registerSpace", &exatn::numerics::SpaceRegister::registerSpace, "")
.def("registerSubspace",
&exatn::numerics::SpaceRegister::registerSubspace, "")
.def("getSubspace", &exatn::numerics::SpaceRegister::getSubspace, "")
.def("getSubspace",
(const exatn::numerics::Subspace *(
exatn::numerics::SpaceRegister::*)(SpaceId,SubspaceId) const) &
exatn::numerics::SpaceRegister::getSubspace,
"")
.def("getSpace",
(const exatn::numerics::VectorSpace *(
exatn::numerics::SpaceRegister::*)(SpaceId) const) &
......
/** ExaTN::Numerics: Register of vector spaces and their subspaces
REVISION: 2020/02/28
REVISION: 2020/03/02
Copyright (C) 2018-2020 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2020 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -121,6 +121,14 @@ SubspaceId SpaceRegister::registerSubspace(std::shared_ptr<Subspace> subspace)
return subspace_register.registerSubspace(subspace);
}
const Subspace * SpaceRegister::getSubspace(SpaceId space_id,
SubspaceId subspace_id) const
{
assert(space_id != SOME_SPACE && space_id < spaces_.size());
const SubspaceRegister & subspace_register = spaces_[space_id].subspaces_;
return subspace_register.getSubspace(subspace_id);
}
const Subspace * SpaceRegister::getSubspace(const std::string & space_name,
const std::string & subspace_name) const
{
......
/** ExaTN::Numerics: Register of vector spaces and their subspaces
REVISION: 2020/02/28
REVISION: 2020/03/02
Copyright (C) 2018-2020 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2020 Oak Ridge National Laboratory (UT-Battelle) **/
......@@ -128,6 +128,8 @@ public:
SubspaceId registerSubspace(std::shared_ptr<Subspace> subspace);
/** Returns a non-owning pointer to a registerd subspace of a registered vector space. **/
const Subspace * getSubspace(SpaceId space_id,
SubspaceId subspace_id) const;
const Subspace * getSubspace(const std::string & space_name,
const std::string & subspace_name) const;
......
/** ExaTN:: Tensor Runtime: Tensor graph node executor: Talsh
REVISION: 2020/02/28
REVISION: 2020/03/02
Copyright (C) 2018-2020 Dmitry Lyakh, Tiffany Mintz, Alex McCaskey
Copyright (C) 2018-2020 Oak Ridge National Laboratory (UT-Battelle)
......@@ -8,6 +8,7 @@ Copyright (C) 2018-2020 Oak Ridge National Laboratory (UT-Battelle)
#include "node_executor_talsh.hpp"
#include <complex>
#include <limits>
#include <mutex>
#include <cstdlib>
......@@ -162,10 +163,19 @@ int TalshNodeExecutor::execute(numerics::TensorOpSlice & op,
auto space_id = slice_signature.getDimSpaceId(i);
auto subspace_id = slice_signature.getDimSubspaceId(i);
if(space_id == SOME_SPACE){
if(subspace_id > std::numeric_limits<int>::max()){
std::cout << "#ERROR(exatn::runtime::node_executor_talsh): SLICE: Integer (int) overflow in offsets" << std::endl;
assert(false);
}
offsets[i] = static_cast<int>(subspace_id);
}else{
const auto * space = getSpaceRegister()->getSpace(space_id);
assert(false); //`finish
const auto * subspace = getSpaceRegister()->getSubspace(space_id,subspace_id);
auto lower_bound = subspace->getLowerBound();
if(lower_bound > std::numeric_limits<int>::max()){
std::cout << "#ERROR(exatn::runtime::node_executor_talsh): SLICE: Integer (int) overflow in offsets" << std::endl;
assert(false);
}
offsets[i] = static_cast<int>(lower_bound);
}
}
......@@ -218,10 +228,19 @@ int TalshNodeExecutor::execute(numerics::TensorOpInsert & op,
auto space_id = slice_signature.getDimSpaceId(i);
auto subspace_id = slice_signature.getDimSubspaceId(i);
if(space_id == SOME_SPACE){
if(subspace_id > std::numeric_limits<int>::max()){
std::cout << "#ERROR(exatn::runtime::node_executor_talsh): INSERT: Integer (int) overflow in offsets" << std::endl;
assert(false);
}
offsets[i] = static_cast<int>(subspace_id);
}else{
const auto * space = getSpaceRegister()->getSpace(space_id);
assert(false); //`finish
const auto * subspace = getSpaceRegister()->getSubspace(space_id,subspace_id);
auto lower_bound = subspace->getLowerBound();
if(lower_bound > std::numeric_limits<int>::max()){
std::cout << "#ERROR(exatn::runtime::node_executor_talsh): INSERT: Integer (int) overflow in offsets" << std::endl;
assert(false);
}
offsets[i] = static_cast<int>(lower_bound);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment