text
stringlengths
0
2.2M
case prim::If: {
assignExitContinuations(n->blocks().at(0));
assignExitContinuations(n->blocks().at(1));
} break;
case prim::Closure: {
LoopContinuations closure_block;
closure_block.run(n->blocks().at(0));
} break;
case prim::Loop: {
Node* prev_loop = curr_loop_;
curr_loop_ = n;
assignExitContinuations(n->blocks().at(0));
curr_loop_ = prev_loop;
} break;
case prim::ContinueStmt: {
auto loop_continuation =
graph_->create(prim::LoopContinuation, 0)->insertAfter(n);
auto header_block = loop_continuation->addBlock();
// NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage)
auto pre_header = curr_loop_->blocks().at(1);
header_block->cloneFrom(pre_header, [](Value* v) { return v; });
InlineBlockBeforeNode(n, header_block);
loop_continuation->addInput(header_block->outputs().at(0));
loop_continuation->eraseBlock(0);
addLoopCarriedOutputs(loop_continuation);
n->destroy();
} break;
case prim::BreakStmt: {
auto loop_exit =
graph_->create(prim::LoopContinuation, 0)->insertAfter(n);
// first input is the loop continue condition - break sets false
loop_exit->addInput(false_val_);
addLoopCarriedOutputs(loop_exit);
n->destroy();
} break;
}
}
}
void run(Block* b) {
{
graph_ = b->owningGraph();
WithInsertPoint guard(b->nodes().front());
false_val_ = graph_->insertConstant(false);
}
assignExitContinuations(b);
}
Graph* graph_ = nullptr;
Value* false_val_ = nullptr;
Node* curr_loop_ = nullptr;
};
// Converting to SSA works in multiple parts. First, we add control flow
// loads and stores to the graph. Now that control flow outputs are set,
// we can set remove Break & Continue to have the correct continuations to the
// end of the block (LoopContinuation). Then we inline the loop condition into
// the graph. Then, we erase Loads & Stores. Finally, we remove
// LoopContinuations from the graph.
void ConvertToSSA(std::shared_ptr<Graph>& graph) {
ControlFlowLoadStores ctrl;
ctrl.run(graph);
LoopContinuations exit_vars;
exit_vars.run(graph);
InlineLoopCondition(graph);
EraseLoadStores erase_loads_stores;
erase_loads_stores.run(graph);
TransformExits(graph);
}
} // namespace jit
} // namespace torch
#include "demoParticle.h"
//------------------------------------------------------------------
demoParticle::demoParticle(){
attractPoints = NULL;
}
//------------------------------------------------------------------
void demoParticle::setMode(particleMode newMode){
mode = newMode;
}
//------------------------------------------------------------------
void demoParticle::setAttractPoints( vector <glm::vec3> * attract ){
attractPoints = attract;
}
//------------------------------------------------------------------
void demoParticle::reset(){
//the unique val allows us to set properties slightly differently for each particle
uniqueVal = ofRandom(-10000, 10000);
pos.x = ofRandomWidth();
pos.y = ofRandomHeight();
pos.z = 0;