Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] dynamic shape & cfg #736

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add new ODLA for slice; Temporary
  • Loading branch information
Weiming Zhao committed Dec 14, 2021
commit 05f052c87323b36d16ed9da65456e5a78cc91e27
25 changes: 18 additions & 7 deletions lib/target/generic_cpp/slice.cc
Original file line number Diff line number Diff line change
@@ -50,7 +50,24 @@ static void NormalizerOperands(const Constant& operand,
} // end namespace

void GenericCXXCodeGen::RunOnInstruction(SliceInst* inst) {
const Def input = inst->GetOperand(0);
const Def& input = inst->GetOperand(0);
const Def& start = inst->GetOperand(1);
const Def& size = inst->GetOperand(2);
// auto strides = inst->GetOperand(3); //TODO

CXXValue op0 = ir_mapping_[input];
CXXValue ret(inst->GetName(), op0.type);
ir_mapping_[*inst] = ret;

if (!IsA<Constant>(start) || !IsA<Constant>(size)) {
auto op1 = ir_mapping_[start];
auto op2 = ir_mapping_[size];
// auto op3 = ir_mapping_[strides]; // FIXME
EmitODLACall(ret, "odla_SliceDynamic", op0, op1, op2, /*op3,*/
EmitShape(inst->GetResultType()));

return;
}
size_t dims = input.GetType().GetNumOfDims();
std::unordered_set<int32_t> axes;
if (inst->GetNumOfOperands() > 4) {
@@ -75,7 +92,6 @@ void GenericCXXCodeGen::RunOnInstruction(SliceInst* inst) {
}

std::vector<uint32_t> start_v(dims, 0);
const Def& start = inst->GetOperand(1);
HLCHECK(start.GetType().GetTotalNumOfElements() ==
static_cast<int64_t>(axes.size()));
HLCHECK(IsA<Constant>(start));
@@ -88,7 +104,6 @@ void GenericCXXCodeGen::RunOnInstruction(SliceInst* inst) {

std::vector<uint32_t> size_v(input.GetType().GetDimSizes().begin(),
input.GetType().GetDimSizes().end());
const Def& size = inst->GetOperand(2);
HLCHECK(size.GetType().GetTotalNumOfElements() ==
static_cast<int64_t>(axes.size()));
HLCHECK(IsA<Constant>(size));
@@ -125,12 +140,8 @@ void GenericCXXCodeGen::RunOnInstruction(SliceInst* inst) {
size_v.begin(), std::plus<uint32_t>());
}

CXXValue op0 = ir_mapping_[input];
CXXValue ret(inst->GetName(), op0.type);

EmitODLACall(ret, "odla_Slice", op0, start_v, size_v, strides_v,
EmitShape(inst->GetResultType()));
ir_mapping_[*inst] = ret;
}

} // namespace halo