Skip to content
Snippets Groups Projects
Commit 5c894d17 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Limit SGM memory usage

parent a7b7d49f
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,8 @@ class FixstarsSGM : public ftl::operators::Operator { ...@@ -30,6 +30,8 @@ class FixstarsSGM : public ftl::operators::Operator {
inline Operator::Type type() const override { return Operator::Type::OneToOne; } inline Operator::Type type() const override { return Operator::Type::OneToOne; }
bool apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, cudaStream_t stream) override; bool apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, cudaStream_t stream) override;
bool isMemoryHeavy() const override { return true; }
private: private:
bool init(); bool init();
bool updateParameters(); bool updateParameters();
......
...@@ -54,6 +54,8 @@ class Operator { ...@@ -54,6 +54,8 @@ class Operator {
*/ */
virtual void wait(cudaStream_t) {} virtual void wait(cudaStream_t) {}
virtual bool isMemoryHeavy() const { return false; }
inline ftl::Configurable *config() const { return config_; } inline ftl::Configurable *config() const { return config_; }
private: private:
......
...@@ -59,14 +59,15 @@ bool Graph::apply(FrameSet &in, FrameSet &out, cudaStream_t stream) { ...@@ -59,14 +59,15 @@ bool Graph::apply(FrameSet &in, FrameSet &out, cudaStream_t stream) {
//while (i.instances.size() < in.frames.size()) { //while (i.instances.size() < in.frames.size()) {
//i.instances.push_back(i.maker->make()); //i.instances.push_back(i.maker->make());
//} //}
if (in.frames.size() > 1 && i.instances.size() < 2) { if (in.frames.size() > 1 && i.instances.size() < 2 && !i.instances[0]->isMemoryHeavy()) {
i.instances.push_back(i.maker->make()); i.instances.push_back(i.maker->make());
} }
for (size_t j=0; j<in.frames.size(); ++j) { for (size_t j=0; j<in.frames.size(); ++j) {
if (!in.hasFrame(j)) continue; if (!in.hasFrame(j)) continue;
auto *instance = i.instances[j&0x1]; int iix = (i.instances[0]->isMemoryHeavy()) ? 0 : j&0x1;
auto *instance = i.instances[iix];
if (instance->enabled()) { if (instance->enabled()) {
try { try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment