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
1 change: 1 addition & 0 deletions README/ReleaseNotes/v642/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The following people have contributed to this new version:
* Several enums that are redundant with `ROOT::ESTLType` are deprecated and will be removed in ROOT 6.44: `TClassEdit::ESTLType`, `TDictionary::ESTLType`, `TStreamerElement::ESTLType`. Please use `ROOT::ESTLType` instead.
* The inclusion by external projects of Makefile templates contained within ROOT is deprecated in 6.42, a warning will be raised if you use them. These files will be removed in ROOT 7.
* The conversion from Python set to **RooArgSet** is deprecated and won't work anymore in ROOT 6.44. The problem is that Python sets are unordered while RooArgSets are ordered, and this mismatch can lead to subtle problems later on. Prefer conversion from Python lists or tuples, which are ordered too.
* The ROOT IO capability for the `TMVA::Experimental::SOFIE::RModel` has been removed. Users should not be encouraged to serialize models in experimental classes. For the serialization of ONNX models one can already use ONNX directly, and even serialize the ONNX bytes to a ROOT file if required.

## Python Interface

Expand Down
2 changes: 1 addition & 1 deletion tmva/sofie/inc/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma link C++ namespace TMVA::Experimental::SOFIE;
#pragma link C++ class TMVA::Experimental::SOFIE::RModel_Base+;
#pragma link C++ class TMVA::Experimental::SOFIE::RModel-;
#pragma link C++ class TMVA::Experimental::SOFIE::RModel+;
#pragma link C++ class TMVA::Experimental::SOFIE::ROperator+;
#pragma link C++ struct TMVA::Experimental::SOFIE::InitializedTensor+;
#pragma link C++ struct TMVA::Experimental::SOFIE::TensorInfo+;
Expand Down
4 changes: 2 additions & 2 deletions tmva/sofie/inc/TMVA/RModel.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ public:
}
bool UseVDT() const { return fUseVDT;}

// Use the ClassDef macro to allow definition of custom streaming
ClassDefNV(RModel, 4);
// RModel is an internal representation that doesn't support ROOT IO (if you need model IO, use ONNX directly).
ClassDefNV(RModel, 0);
};

// need to implement here templated member functions and its specialization
Expand Down
37 changes: 0 additions & 37 deletions tmva/sofie/inc/TMVA/SOFIE_common.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -312,49 +312,12 @@ public:
return static_cast<T const *>(fData.get());
}

void CastSharedToPersistent()
{
// We only calculate fSize here, because it is only used for IO to know
// the size of the persistent data.
fSize = 1;
for (std::size_t item : fShape) {
fSize *= static_cast<int>(item);
}
// get size in bytes
fSize *= GetTypeSize(fType);
fPersistentData = static_cast<char *>(fData.get());
}
void CastPersistentToShared()
{
// If there is no persistent data, do nothing
if (fSize == 0 || fPersistentData == nullptr) {
return;
}

// Nothing to be done if the pointed-to data is the same
if (fPersistentData == static_cast<char *>(fData.get())) {
return;
}

// Initialize the shared_ptr
fData = std::shared_ptr<void>{malloc(fSize), free};
std::memcpy(fData.get(), fPersistentData, fSize);

// Make sure the data read from disk doesn't leak and delete the
// persistent data
delete[] fPersistentData;
fPersistentData = nullptr;
fSize = 0;
}

private:
bool fConstant = false; ///< Flag specifying if tensor is a Constant one (coming from a Constant operator)
bool fIsNotWritable = false; ///< Flag to indicate that tensor values do not need to be written as weight or generated code
ETensorType fType; ///< Encodes the type of the data
std::vector<std::size_t> fShape; ///< The shape of the data in terms of elements in each dimension
std::shared_ptr<void> fData; ///<! Transient shared data
int fSize = 0; ///< The size of the persistent data in bytes (not number of elements!)
char *fPersistentData = nullptr; ///<[fSize] Persistent version of the data
};

template <typename T>
Expand Down
15 changes: 0 additions & 15 deletions tmva/sofie/src/RModel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1978,19 +1978,4 @@ void RModel::OutputGenerated(std::string filename, bool append) {
}
}

void RModel::Streamer(TBuffer &R__b) {
if (R__b.IsReading()) {
RModel::Class()->ReadBuffer(R__b, this);
for (auto & i : fInitializedTensors) {
i.second.CastPersistentToShared();
}
}
else {
for (auto & i : fInitializedTensors) {
i.second.CastSharedToPersistent();
}
RModel::Class()->WriteBuffer(R__b, this);
}
}

} // namespace SOFIE::Experimental::TMVA
28 changes: 0 additions & 28 deletions tmva/sofie/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ foreach(onnx_file ${ONNX_FILES})
endforeach()
string(REPLACE ";" ";\n" EMIT_CAPTURES "${ALL_CAPTURES}")
configure_file(EmitFromONNX.cxx.in EmitFromONNX_all.cxx @ONLY)
configure_file(EmitFromRoot.cxx.in EmitFromRoot_all.cxx @ONLY)

ROOTTEST_GENERATE_EXECUTABLE(emitFromONNX EmitFromONNX_all.cxx
LIBRARIES protobuf::libprotobuf ROOTTMVASofie ROOTTMVASofieParser
Expand Down Expand Up @@ -64,34 +63,7 @@ if (BLAS_FOUND) # we need BLAS for compiling the models
endif()
endif()

# For testing serialisation of RModel object

ROOTTEST_GENERATE_EXECUTABLE(emitFromROOT EmitFromRoot_all.cxx
LIBRARIES protobuf::libprotobuf RIO ROOTTMVASofie ROOTTMVASofieParser
FIXTURES_SETUP sofie-compile-models-onnx-root
)
# silence protobuf warnings seen in version 3.0 and 3.6. Not needed from protobuf version 3.17
target_compile_options(emitFromROOT PRIVATE -Wno-unused-parameter -Wno-array-bounds)

# Automatic compilation of headers from root files
ROOTTEST_ADD_TEST(SofieCompileModels_ROOT
COMMAND ${CMAKE_COMMAND} -E env ROOTIGNOREPREFIX=1 ./emitFromROOT
FIXTURES_REQUIRED sofie-compile-models-onnx-root
FIXTURES_SETUP sofie-compile-models-root
)

if (BLAS_FOUND)
# Creating a Google Test for Serialisation of RModel
ROOT_EXECUTABLE(TestCustomModelsFromROOT TestCustomModelsFromROOT.cxx
LIBRARIES
Core
GTest::gtest
GTest::gtest_main
)
ROOTTEST_ADD_TEST(TestCustomModelsFromROOT
EXEC ./TestCustomModelsFromROOT
FIXTURES_REQUIRED sofie-compile-models-root)

if (clad)
# Creating a Google Test for the automatic differentiation of Gemm_Call
ROOT_ADD_GTEST(TestGemmDerivative TestGemmDerivative.cxx LIBRARIES Core BLAS::BLAS)
Expand Down
48 changes: 0 additions & 48 deletions tmva/sofie/test/EmitFromRoot.cxx.in

This file was deleted.

Loading
Loading