Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions tmva/sofie/inc/TMVA/ROperator_BasicBinary.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ public:
}
if (dynamicInputs & 1 && model.Verbose())
std::cout << BinaryOperatorTrait<T, Op>::Name() << " : input " << fNA << " is dynamic "
<< ConvertShapeToString(fDimShapeA) << std::endl;
<< ConvertDimShapeToString(fDimShapeA) << std::endl;
if (dynamicInputs & 2 && model.Verbose())
std::cout << BinaryOperatorTrait<T, Op>::Name() << " : input " << fNB << " is dynamic "
<< ConvertShapeToString(fDimShapeB) << std::endl;
<< ConvertDimShapeToString(fDimShapeB) << std::endl;

// check if need to broadcast at initialization time if shapes are known and different
// (we could broadcast the tensor tensor to maximum values of dynamic shapes - to be done)
Expand Down Expand Up @@ -259,8 +259,8 @@ public:

model.AddIntermediateTensor(fNY, model.GetTensorType(fNA), fDimShapeY);
if (model.Verbose()) {
std::cout << BinaryOperatorTrait<T, Op>::Name() << " : " << ConvertShapeToString(fDimShapeA) << " , "
<< ConvertShapeToString(fDimShapeB) << " --> " << ConvertShapeToString(fDimShapeY) << std::endl;
std::cout << BinaryOperatorTrait<T, Op>::Name() << " : " << ConvertDimShapeToString(fDimShapeA) << " , "
<< ConvertDimShapeToString(fDimShapeB) << " --> " << ConvertDimShapeToString(fDimShapeY) << std::endl;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions tmva/sofie/inc/TMVA/ROperator_BasicNary.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ public:
if (model.Verbose()) {
std::cout << NaryOperatorTraits<T, Op>::Name() << " : ";
if (fNInputs.size() == 2)
std::cout << ConvertShapeToString(fShapeInputs[0]) << " , "
<< ConvertShapeToString(fShapeInputs[1]);
std::cout << " --> " << ConvertShapeToString(fDimShapeY) << std::endl;
std::cout << ConvertDimShapeToString(fShapeInputs[0]) << " , "
<< ConvertDimShapeToString(fShapeInputs[1]);
std::cout << " --> " << ConvertDimShapeToString(fDimShapeY) << std::endl;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tmva/sofie/inc/TMVA/ROperator_BatchNormalization.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public:

if (fShapeX.size() < 2 || fShapeX.size() > 4) {
throw
std::runtime_error("TMVA SOFIE BatchNormalization Op input tensor " + fNX + " fnx has wrong shape : " + ConvertShapeToString(fShapeX));
std::runtime_error("TMVA SOFIE BatchNormalization Op input tensor " + fNX + " fnx has wrong shape : " + ConvertDimShapeToString(fShapeX));
}

fShapeY = fShapeX;
Expand Down
6 changes: 3 additions & 3 deletions tmva/sofie/inc/TMVA/ROperator_Comparision.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ public:

model.AddIntermediateTensor(fNY, ETensorType::BOOL, fDimShapeY);
if (model.Verbose()) {
std::cout << ComparisionTrait<T, Op>::Name() << " : " << fNX1 << " " << ConvertShapeToString(fDimShapeX1) << " , "
<< fNX2 << " " << ConvertShapeToString(fDimShapeX2) << " --> "
<< fNY << " " << ConvertShapeToString(fDimShapeY) << std::endl;
std::cout << ComparisionTrait<T, Op>::Name() << " : " << fNX1 << " " << ConvertDimShapeToString(fDimShapeX1) << " , "
<< fNX2 << " " << ConvertDimShapeToString(fDimShapeX2) << " --> "
<< fNY << " " << ConvertDimShapeToString(fDimShapeY) << std::endl;
model.PrintIntermediateTensors();
}
}
Expand Down
10 changes: 5 additions & 5 deletions tmva/sofie/inc/TMVA/ROperator_Concat.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
for (size_t i = 0; i < inputs.size(); i++) {
if (i > 0 && inputs[i].size() != inputs[i - 1].size())
throw std::runtime_error("TMVA SOFIE Concat Op - input tensors have different shapes " + fInputs[i] + " : " +
ConvertShapeToString(inputs[i]) + " and " + fInputs[i-1] + " : " + ConvertShapeToString(inputs[i - 1]));
ConvertDimShapeToString(inputs[i]) + " and " + fInputs[i-1] + " : " + ConvertDimShapeToString(inputs[i - 1]));
for (size_t iaxis = 0; iaxis < inputs[i].size(); iaxis++) {
if ((int)iaxis == fAxis) {
// support both integer and params shape for the concatenation axis
Expand All @@ -134,8 +134,8 @@
}
else if ((!inputs[i][iaxis].isParam && !ret[iaxis].isParam) && (inputs[i][iaxis].dim != ret[iaxis].dim)) {
throw std::runtime_error("TMVA SOFIE Concat Op - input tensors have wrong shapes " +
ConvertShapeToString(inputs[i]) + " and " +
ConvertShapeToString(inputs[i - 1]));
ConvertDimShapeToString(inputs[i]) + " and " +
ConvertDimShapeToString(inputs[i - 1]));
}
else if (!inputs[i][iaxis].isParam && ret[iaxis].isParam){
// if shape is not parametric use it
Expand Down Expand Up @@ -240,7 +240,7 @@
model.AddShapeTensor(fOutput,outputData, false); // cannot be a scalar
if (model.Verbose()) {
std::cout << "output of Concat is a shape tensor " << ConvertShapeToString(outputShape) << " : "
<< ConvertShapeToString(outputData) << " (shape)" << std::endl;
<< ConvertDimShapeToString(outputData) << " (shape)" << std::endl;
}
fIsOutputConstant = true;
}
Expand All @@ -256,7 +256,7 @@
std::string Generate(std::string opName) override {
opName = "op_" + opName;
std::stringstream out;
out<<"\n//--------- Concat " << opName << " --> " << fOutput << " " << ConvertShapeToString(fOutputShape) << "\n";
out<<"\n//--------- Concat " << opName << " --> " << fOutput << " " << ConvertDimShapeToString(fOutputShape) << "\n";

if (fIsOutputConstant) return out.str();

Expand Down
6 changes: 3 additions & 3 deletions tmva/sofie/inc/TMVA/ROperator_Constant.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ public:
std::stringstream out;
if (fIsOutputConstant) {
if (fNX.empty())
out << "// ---- Constant (no-op) " << opName << " --> " << fNY << " " << ConvertShapeToString(fDimOutputShape) << "\n";
out << "// ---- Constant (no-op) " << opName << " --> " << fNY << " " << ConvertDimShapeToString(fDimOutputShape) << "\n";
else
out << "// ---- ConstantOfShape (no-op) " << opName << " --> " << fNY << " " << ConvertShapeToString(fDimOutputShape) << "\n";
out << "// ---- ConstantOfShape (no-op) " << opName << " --> " << fNY << " " << ConvertDimShapeToString(fDimOutputShape) << "\n";
return out.str();
}
// Only ConstantOfShape might require generation code
// generate constant tensor according to input

out << "\n//--------- ConstantOfShape " << opName << " --> " << ConvertShapeToString(fDimOutputShape) << "\n";
out << "\n//--------- ConstantOfShape " << opName << " --> " << ConvertDimShapeToString(fDimOutputShape) << "\n";
// set shape values if needed
if (fIsUndefinedInputShape) {
for (size_t i = 0; i < fDimOutputShape.size(); i++) {
Expand Down
8 changes: 4 additions & 4 deletions tmva/sofie/inc/TMVA/ROperator_Conv.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public:
}
fShapeX = model.GetDimTensorShape(fNX);
if (fShapeX.size() < 3 || fShapeX.size() > 5) {
std::cout << fNX << " : " << ConvertShapeToString(fShapeX) << std::endl;
std::cout << fNX << " : " << ConvertDimShapeToString(fShapeX) << std::endl;
throw
std::runtime_error("TMVA SOFIE Conv Op input data tensor" + fNX + " is not of 3,4 or 5 dimensions");
}
Expand Down Expand Up @@ -325,8 +325,8 @@ public:
fInputTensorNames.emplace_back(imcol);

if (model.Verbose()) {
std::cout << "Conv - " << fDim << " " << fNX << " : " << ConvertShapeToString(fShapeX)
<< " --> " << fNY << " : " << ConvertShapeToString(fShapeY) << std::endl;
std::cout << "Conv - " << fDim << " " << fNX << " : " << ConvertDimShapeToString(fShapeX)
<< " --> " << fNY << " : " << ConvertDimShapeToString(fShapeY) << std::endl;
}
}

Expand All @@ -348,7 +348,7 @@ public:
else
out << SP << "{\n";
out << SP << SP << "float * data = TMVA::Experimental::SOFIE::UTILITY::UnidirectionalBroadcast(tensor_"
<< fNB << ", " << ConvertShapeToString(shape) << ", " << ConvertShapeToString(fShapeY) << ");\n";
<< fNB << ", " << ConvertShapeToString(shape) << ", " << ConvertDimShapeToString(fShapeY) << ");\n";
out << SP << SP << "fTensor_" << fNB << ".resize(" << length << ");\n";
out << SP << SP << "std::copy(data, data + " << length << ", fTensor_" << fNB << ".begin());\n";
out << SP << SP << "tensor_" << fNB << " = fTensor_" << fNB << ".data();\n";
Expand Down
8 changes: 4 additions & 4 deletions tmva/sofie/inc/TMVA/ROperator_Expand.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public:
}
fType = ConvertTypeToString(model.GetTensorType(fNX));
if (model.Verbose()) {
std::cout << "Expand - input " << fNX << " shape " << ConvertShapeToString(fShapeX) << " --> " << fNY << " shape "
<< ConvertShapeToString(fShapeY) << (fIsOutputConstant ? ConvertValuesToString(model.GetTensorData<T>(fNY)) + " (constant)" : "") << std::endl;
std::cout << "Expand - input " << fNX << " shape " << ConvertDimShapeToString(fShapeX) << " --> " << fNY << " shape "
<< ConvertDimShapeToString(fShapeY) << (fIsOutputConstant ? ConvertValuesToString(model.GetTensorData<T>(fNY)) + " (constant)" : "") << std::endl;
}
}

Expand All @@ -143,7 +143,7 @@ public:
throw std::runtime_error("TMVA SOFIE Expand Op called to Generate without being initialized first");
}
std::stringstream out;
out << SP << "\n//------ Expand " << opName << " --> " << ConvertShapeToString(fShapeY) << "\n";
out << SP << "\n//------ Expand " << opName << " --> " << ConvertDimShapeToString(fShapeY) << "\n";
// need to declare shape parameters for non initialized shapes
if (!fInitializedShape) {
for (size_t i = 0; i < fShapeDim.size(); i++) {
Expand All @@ -153,7 +153,7 @@ public:
// No need to broadcast A if it's an initialized tensor or shapes are the same
if (!fInitialized && fShapeX != fShapeY) {
out << SP << "// Broadcasting uninitialized tensor " << fNX << "\n";
out << SP << "TMVA::Experimental::SOFIE::UTILITY::UnidirectionalBroadcast(tensor_" << fNX << ", " << ConvertShapeToString(fShapeX) << ", " << ConvertShapeToString(fShapeY)
out << SP << "TMVA::Experimental::SOFIE::UTILITY::UnidirectionalBroadcast(tensor_" << fNX << ", " << ConvertDimShapeToString(fShapeX) << ", " << ConvertDimShapeToString(fShapeY)
<< ", tensor_"<<fNY<<");\n";
}
return out.str();
Expand Down
18 changes: 9 additions & 9 deletions tmva/sofie/inc/TMVA/ROperator_Gather.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public:
}
fShapeX = model.GetDimTensorShape(fNX);
if (model.Verbose())
std::cout << "Gather - initial shape " << ConvertShapeToString(fShapeX) << " shape of indices "
<< ConvertShapeToString(model.GetDimTensorShape(fNIndices)) << std::endl;
std::cout << "Gather - initial shape " << ConvertDimShapeToString(fShapeX) << " shape of indices "
<< ConvertDimShapeToString(model.GetDimTensorShape(fNIndices)) << std::endl;
// fShapeIndices can be dynamic
fShapeIndices = model.GetDimTensorShape(fNIndices);
size_t q = fShapeIndices.size();
Expand Down Expand Up @@ -86,7 +86,7 @@ public:
}
// Output shape
if (model.Verbose())
std::cout << "Gather: q and r " << q << " " << r << " shape indices " << ConvertShapeToString(fShapeIndices) << std::endl;
std::cout << "Gather: q and r " << q << " " << r << " shape indices " << ConvertDimShapeToString(fShapeIndices) << std::endl;

if (fShapeY.empty()) {
fShapeY.resize(q + r - 1);
Expand Down Expand Up @@ -128,15 +128,15 @@ public:
// shapeY can be scalar or vector of size1
model.AddShapeTensor(fNY, outputData, fShapeY.size() == 0);
if (model.Verbose())
std::cout << "Gather: " << fNX << " " << ConvertShapeToString(fShapeX) << " -> " << fNY << " with shape " << ConvertShapeToString(fShapeY)
<< " and values " << ConvertShapeToString(outputData) << " (shape) " << std::endl;
std::cout << "Gather: " << fNX << " " << ConvertDimShapeToString(fShapeX) << " -> " << fNY << " with shape " << ConvertDimShapeToString(fShapeY)
<< " and values " << ConvertDimShapeToString(outputData) << " (shape) " << std::endl;
} else {
int64_t value = static_cast<int64_t>(outputData[0].dim);
auto shapeY = ConvertShapeToInt(fShapeY);
model.AddConstantTensor(fNY, shapeY, &value);
fIsOutputConstant = true;
if (model.Verbose())
std::cout << "Gather: " << fNX << " " << ConvertShapeToString(fShapeX) << " -> " << fNY << " with shape " << ConvertShapeToString(fShapeY)
std::cout << "Gather: " << fNX << " " << ConvertDimShapeToString(fShapeX) << " -> " << fNY << " with shape " << ConvertDimShapeToString(fShapeY)
<< " and values {" << value << "} (constant) " << std::endl;
}
}
Expand All @@ -145,15 +145,15 @@ public:
model.AddIntermediateTensor(fNY, model.GetTensorType(fNX), fShapeY);
fType = ConvertTypeToString(model.GetTensorType(fNX));
if (model.Verbose())
std::cout << "Gather: input " << fNX << " " << ConvertShapeToString(fShapeX) << " indices " << fNIndices << ConvertShapeToString(fShapeIndices)
<< " -> " << fNY << " with shape " << ConvertShapeToString(fShapeY) << std::endl;
std::cout << "Gather: input " << fNX << " " << ConvertDimShapeToString(fShapeX) << " indices " << fNIndices << ConvertDimShapeToString(fShapeIndices)
<< " -> " << fNY << " with shape " << ConvertDimShapeToString(fShapeY) << std::endl;
}
}

std::string Generate(std::string opName) override {
opName = "op_" + opName;
std::stringstream out;
out << "//--------- Gather " << opName << " --> " << fNY << " " << ConvertShapeToString(fShapeY) << "\n";
out << "//--------- Gather " << opName << " --> " << fNY << " " << ConvertDimShapeToString(fShapeY) << "\n";
if (fIsOutputConstant) {
// no code to generate here for constant output. Tensor output is defined in Session constructor
out << "//--------------------(constant)----------\n";
Expand Down
20 changes: 10 additions & 10 deletions tmva/sofie/inc/TMVA/ROperator_GatherND.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public:
}
fShapeX = model.GetDimTensorShape(fNX);
if (model.Verbose())
std::cout << "GatherND - initial shape " << ConvertShapeToString(fShapeX) << " shape of indices "
<< ConvertShapeToString(model.GetDimTensorShape(fNIndices)) << std::endl;
std::cout << "GatherND - initial shape " << ConvertDimShapeToString(fShapeX) << " shape of indices "
<< ConvertDimShapeToString(model.GetDimTensorShape(fNIndices)) << std::endl;
// fShapeIndices can be dynamic
fShapeIndices = model.GetDimTensorShape(fNIndices);
size_t q = fShapeIndices.size();
Expand All @@ -64,8 +64,8 @@ public:
if (fBatchDims > 0) {
for (size_t i = 0; i < fBatchDims; i++) {
if (fShapeX[i] != fShapeIndices[i]) {
std::cout << " input shape " << ConvertShapeToString(fShapeX) << " "
<< " index shape " << ConvertShapeToString(fShapeIndices) << std::endl;
std::cout << " input shape " << ConvertDimShapeToString(fShapeX) << " "
<< " index shape " << ConvertDimShapeToString(fShapeIndices) << std::endl;
throw std::runtime_error("TMVA SOFIE GatherND : invalid input or index shape for " + std::to_string(i));
}
}
Expand All @@ -89,9 +89,9 @@ public:
fShapeY = std::vector<Dim>(fShapeIndices.begin(), fShapeIndices.end() - 1);
fShapeY.insert(fShapeY.end(), fShapeX.begin() + fBatchDims + last_index_shape, fShapeX.end());
if (fShapeY.size() != output_rank) {
std::cout << " input shape " << ConvertShapeToString(fShapeX) << " "
<< " index shape " << ConvertShapeToString(fShapeIndices)
<< " output shape " << ConvertShapeToString(fShapeY)
std::cout << " input shape " << ConvertDimShapeToString(fShapeX) << " "
<< " index shape " << ConvertDimShapeToString(fShapeIndices)
<< " output shape " << ConvertDimShapeToString(fShapeY)
<< " and output rank should be " << output_rank << std::endl;
throw std::runtime_error("TMVA SOFIE GatherND : Something is wrong in initialization ");
}
Expand All @@ -101,8 +101,8 @@ public:
model.AddIntermediateTensor(fNY, model.GetTensorType(fNX), fShapeY);
fType = ConvertTypeToString(model.GetTensorType(fNX));
if (model.Verbose())
std::cout << "GatherND: input " << fNX << " " << ConvertShapeToString(fShapeX) << " indices " << fNIndices << ConvertShapeToString(fShapeIndices)
<< " -> " << fNY << " with shape " << ConvertShapeToString(fShapeY) << std::endl;
std::cout << "GatherND: input " << fNX << " " << ConvertDimShapeToString(fShapeX) << " indices " << fNIndices << ConvertDimShapeToString(fShapeIndices)
<< " -> " << fNY << " with shape " << ConvertDimShapeToString(fShapeY) << std::endl;
}


Expand Down Expand Up @@ -176,7 +176,7 @@ public:
}
opName = "op_" + opName;
std::stringstream out;
out << "//--------- GatherND " << opName << " --> " << ConvertShapeToString(fShapeY) << "\n";
out << "//--------- GatherND " << opName << " --> " << ConvertDimShapeToString(fShapeY) << "\n";
// The shape of the output is q + r - 1
size_t r = fShapeX.size();
// Indices of shape q
Expand Down
6 changes: 3 additions & 3 deletions tmva/sofie/inc/TMVA/ROperator_Gemm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ namespace SOFIE{
if (model.Verbose()){
std::cout << "Gemm (or MatMul) " << " ---> " << fNY << " shape ";
if (fIsDynamic)
std::cout << ConvertShapeToString(fShapeY) << std::endl;
std::cout << ConvertDimShapeToString(fShapeY) << std::endl;
else
std::cout << ConvertShapeToString(shapeY) << std::endl;
}
Expand All @@ -279,8 +279,8 @@ namespace SOFIE{
throw std::runtime_error("TMVA SOFIE Gemm Op called to Generate without being initialized first");
}
std::stringstream out;
out << "\n//--------- Gemm " << opName << " " << ConvertShapeToString(fShapeA) << " * " << ConvertShapeToString(fShapeB)
<< " -> " << ConvertShapeToString(fShapeY) << "\n";
out << "\n//--------- Gemm " << opName << " " << ConvertDimShapeToString(fShapeA) << " * " << ConvertDimShapeToString(fShapeB)
<< " -> " << ConvertDimShapeToString(fShapeY) << "\n";
// need to consider case A and B have dim > 2 (for MatMul)
int64_t dimA = fShapeA.size();
int64_t dimB = fShapeB.size();
Expand Down
2 changes: 1 addition & 1 deletion tmva/sofie/inc/TMVA/ROperator_LayerNormalization.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public:
out << SP << "// Broadcasting the bias of LayerNormalization op\n";
out << SP << "{\n";
out << SP << SP << "float* data = TMVA::Experimental::SOFIE::UTILITY::UnidirectionalBroadcast(tensor_";
out << fNB << ", " << ConvertShapeToString(fShapeB) << ", " << ConvertShapeToString(fShapeX) << ");\n";
out << fNB << ", " << ConvertDimShapeToString(fShapeB) << ", " << ConvertDimShapeToString(fShapeX) << ");\n";
out << SP << "std::copy(data, data + " << fLength << ", tensor_" << fNBroadcastedB << ");\n";
out << SP << "delete[] data;\n";
out << SP << "}\n";
Expand Down
Loading
Loading