From d64ee86a3130f8eeb75d09193c38c621d7565eba Mon Sep 17 00:00:00 2001 From: Yong He Date: Sun, 26 Mar 2023 13:59:11 -0700 Subject: Add PyTorch C++ binding generation. (#2734) * Add PyTorch C++ binding generation. * fix --------- Co-authored-by: Yong He --- source/slang/slang-emit-cpp.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/slang/slang-emit-cpp.cpp') diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index 2a2ae06c6..346926712 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -304,6 +304,18 @@ SlangResult CPPSourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, S out << ">"; return SLANG_OK; } + case kIROp_TargetTupleType: + { + out << "std::tuple<"; + for (UInt i = 0; i < type->getOperandCount(); i++) + { + if (i > 0) out << ", "; + auto elementType = (IRType*)type->getOperand(i); + SLANG_RETURN_ON_FAIL(calcTypeName(elementType, target, out)); + } + out << ">"; + return SLANG_OK; + } default: { if (isNominalOp(type->getOp())) @@ -1187,6 +1199,19 @@ bool CPPSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOut return true; } + case kIROp_MakeTargetTuple: + { + m_writer->emit("std::make_tuple("); + for (UInt i = 0; i < inst->getOperandCount(); i++) + { + if (i > 0) + m_writer->emit(", "); + auto arg = inst->getOperand(i); + emitOperand(arg, getInfo(EmitOp::General)); + } + m_writer->emit(")"); + return true; + } case kIROp_CastFloatToInt: case kIROp_CastIntToFloat: case kIROp_FloatCast: -- cgit v1.2.3