Skip to content

Remove the notinstalled data namespace since data is being installed #370

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

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
54 changes: 54 additions & 0 deletions cmake_files/LookUpONNXRT.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

find_package(onnxruntime QUIET)

if(${onnxruntime_FOUND})
find_path(onnxruntime_INCLUDE_DIR NAMES onnxruntime_cxx_api.h
HINTS
ENV onnxruntime_ROOT
ENV onnxruntime_ROOT_DIR
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR}
PATH_SUFFIXES onnxruntime
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(onnxruntime DEFAULT_MSG onnxruntime_INCLUDE_DIR TRUE)
set(onnxruntime_LIBRARIES onnxruntime::onnxruntime)
get_filename_component(onnxruntime_INSTALL_PREFIX "${onnxruntime_INCLUDE_DIR}/../../" ABSOLUTE)
find_library(onnxruntime_LIBRARY onnxruntime PATHS "${onnxruntime_INSTALL_PREFIX}/lib")
set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION "${onnxruntime_LIBRARY}")
set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${onnxruntime_INCLUDE_DIR}")
endif()

if(NOT ${onnxruntime_FOUND})
message(STATUS "ONNXrt not found. Attempt to install...")
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCH )
message( STATUS "Detected architecture: ${ARCH}" )
if ("${ARCH}" STREQUAL "x86_64")
set(ARCH "x64")
endif()
set(ORT_VERSION "1.16.3")
set(ORT_URL_BASE "https://github.com/microsoft/onnxruntime/releases/download")
set(ORT_TARNAME "onnxruntime-linux-${ARCH}-${ORT_VERSION}")
set(ORT_DEST "${CMAKE_CURRENT_BINARY_DIR}/external/${ORT_TARNAME}.tgz")
set(ORT_URL "${ORT_URL_BASE}/v${ORT_VERSION}/${ORT_TARNAME}.tgz")
# https://cmake.org/cmake/help/latest/policy/CMP0135.html
#
# CMP0135 is for solving re-building and re-downloading.
# The NEW policy suppresses warnings for some CMake versions.
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
set(onnxruntime_DIR "${CMAKE_INSTALL_PREFIX}/external")
file(DOWNLOAD ${ORT_URL} ${ORT_DEST}
EXPECTED_HASH SHA256=b072f989d6315ac0e22dcb4771b083c5156d974a3496ac3504c77f4062eb248e
)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${ORT_DEST})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${ORT_TARNAME} ${onnxruntime_DIR})
set(onnxruntime_INCLUDE_DIR "${onnxruntime_DIR}/include")
set(onnxruntime_LIBRARY_DIR "${onnxruntime_DIR}/lib")
set(onnxruntime_LIBRARIES onnxruntime::onnxruntime)
add_library(${onnxruntime_LIBRARIES} SHARED IMPORTED GLOBAL)
set_target_properties(${onnxruntime_LIBRARIES} PROPERTIES IMPORTED_LOCATION ${onnxruntime_LIBRARY_DIR}/libonnxruntime.so)
set(onnxruntime_FOUND TRUE)
endif()

1 change: 0 additions & 1 deletion cpp/benchmarks/measurement_operator_mpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <sopt/wavelets.h>

using namespace purify;
using namespace purify::notinstalled;

// ----------------- Degrid operator constructor fixture -----------------------//

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/measurement_operator_wproj.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <sopt/wavelets.h>

using namespace purify;
using namespace purify::notinstalled;

// ----------------- Degrid operator constructor fixture -----------------------//

Expand Down
1 change: 0 additions & 1 deletion cpp/benchmarks/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <sopt/linear_transform.h>

using namespace purify;
using namespace purify::notinstalled;

namespace b_utilities {

Expand Down
2 changes: 1 addition & 1 deletion cpp/example/casa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
int main(int, char **) {
purify::logging::set_level(purify::default_logging_level());
// Loads a measurement set
auto const ngc3256_filename = purify::notinstalled::ngc3256_ms();
auto const ngc3256_filename = purify::ngc3256_ms();
auto const ngc3256 = purify::casa::MeasurementSet(ngc3256_filename);

try {
Expand Down
1 change: 0 additions & 1 deletion cpp/example/compare_wprojection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sopt/power_method.h>

using namespace purify;
using namespace purify::notinstalled;

int main(int nargs, char const **args) {
#define ARGS_MACRO(NAME, ARGN, VALUE, TYPE) \
Expand Down
1 change: 0 additions & 1 deletion cpp/example/generate_vis_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

int main(int nargs, char const **args) {
using namespace purify;
using namespace purify::notinstalled;
purify::logging::set_level(purify::default_logging_level());

const std::string &pos_filename = mwa_filename("Phase1_config.txt");
Expand Down
1 change: 0 additions & 1 deletion cpp/example/histogram_equalisation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "purify/directories.h"
#include "purify/pfitsio.h"
using namespace purify;
using namespace purify::notinstalled;

int main(int nargs, char const **args) {
// up samples M31 example
Expand Down
1 change: 0 additions & 1 deletion cpp/example/image_wproj_chirp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <sopt/power_method.h>

using namespace purify;
using namespace purify::notinstalled;

int main(int nargs, char const **args) {
#define ARGS_MACRO(NAME, ARGN, VALUE, TYPE) \
Expand Down
1 change: 0 additions & 1 deletion cpp/example/mem_w_algos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "purify/utilities.h"

using namespace purify;
using namespace purify::notinstalled;

int main(int nargs, char const **args) {
auto const session = sopt::mpi::init(nargs, args);
Expand Down
1 change: 0 additions & 1 deletion cpp/example/padmm_mpi_random_coverage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#endif

using namespace purify;
using namespace purify::notinstalled;

std::tuple<utilities::vis_params, t_real> dirty_visibilities(
Image<t_complex> const &ground_truth_image, t_uint number_of_vis, t_real snr,
Expand Down
1 change: 0 additions & 1 deletion cpp/example/padmm_mpi_real_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#endif

using namespace purify;
using namespace purify::notinstalled;

utilities::vis_params dirty_visibilities(const std::vector<std::string> &names) {
return utilities::read_visibility(names, true);
Expand Down
9 changes: 0 additions & 9 deletions cpp/example/padmm_random_coverage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "purify/pfitsio.h"
#include "purify/utilities.h"
using namespace purify;
using namespace purify::notinstalled;

void padmm(const std::string &name, const Image<t_complex> &M31, const std::string &kernel,
const t_int J, const utilities::vis_params &uv_data, const t_real sigma,
Expand Down Expand Up @@ -182,13 +181,5 @@ int main(int, char **) {
// adding noise to visibilities
uv_data.vis = utilities::add_noise(y0, 0., sigma);
padmm(name + "30", M31, kernel, 4, uv_data, sigma, std::make_tuple(w_term, cellsize));
/*
const std::string &test_dir = "expected/padmm_serial/";
const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis");
auto uv_data = utilities::read_visibility(input_data_path, false);
uv_data.units = utilities::vis_units::radians;
t_real const sigma = 0.02378738741225;
padmm(name + "10", M31, kernel, 4, uv_data, sigma, std::make_tuple(w_term, cellsize));
*/
return 0;
}
1 change: 0 additions & 1 deletion cpp/example/padmm_real_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "purify/uvfits.h"
#include "purify/wproj_utilities.h"
using namespace purify;
using namespace purify::notinstalled;

void padmm(const std::string &name, const t_uint &imsizex, const t_uint &imsizey,
const std::string &kernel, const t_int J, const utilities::vis_params &uv_data,
Expand Down
1 change: 0 additions & 1 deletion cpp/example/padmm_reweighted_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ int main(int nargs, char const **args) {
}

using namespace purify;
using namespace purify::notinstalled;
sopt::logging::set_level("debug");

std::string const kernel = args[1];
Expand Down
1 change: 0 additions & 1 deletion cpp/example/padmm_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ int main(int nargs, char const **args) {
}

using namespace purify;
using namespace purify::notinstalled;
sopt::logging::set_level("debug");
purify::logging::set_level("debug");

Expand Down
1 change: 0 additions & 1 deletion cpp/example/plot_wkernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "purify/wkernel_integration.h"

using namespace purify;
using namespace purify::notinstalled;

using namespace purify;

Expand Down
1 change: 0 additions & 1 deletion cpp/example/sara_padmm_random_coverage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

int main(int, char **) {
using namespace purify;
using namespace purify::notinstalled;
sopt::logging::set_level("info");

std::string const fitsfile = image_filename("M31.fits");
Expand Down
1 change: 0 additions & 1 deletion cpp/example/sdmm_m31_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

int main(int nargs, char const **args) {
using namespace purify;
using namespace purify::notinstalled;

if (nargs != 6) {
PURIFY_CRITICAL(" Wrong number of arguments!");
Expand Down
1 change: 0 additions & 1 deletion cpp/example/show_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "purify/directories.h"
#include "purify/pfitsio.h"
using namespace purify;
using namespace purify::notinstalled;

int main(int nargs, char const **args) {
// up samples M31 example
Expand Down
1 change: 0 additions & 1 deletion cpp/example/time_w_algos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "purify/utilities.h"

using namespace purify;
using namespace purify::notinstalled;

int main(int nargs, char const **args) {
auto const session = sopt::mpi::init(nargs, args);
Expand Down
1 change: 0 additions & 1 deletion cpp/example/wavelet_decomposition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "purify/wavelet_operator_factory.h"

using namespace purify;
using namespace purify::notinstalled;

int main(int nargs, char const **args) {
purify::logging::set_level("debug");
Expand Down
4 changes: 2 additions & 2 deletions cpp/purify/config.in.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
//! Whether PURIFY is using (and SOPT was built with) onnxrt support
#cmakedefine PURIFY_ONNXRT

#include <cstdint>
#include <string>
#include <tuple>
#include <cstdint>

namespace purify {
//! Returns library version
Expand All @@ -46,6 +46,6 @@ inline std::tuple<uint8_t, uint8_t, uint8_t> version_tuple() {
inline std::string gitref() { return "@Purify_GITREF@"; }
//! Default logging level
inline std::string default_logging_level() { return "@PURIFY_TEST_LOG_LEVEL@"; }
} // namespace purify
} // namespace purify

#endif
62 changes: 24 additions & 38 deletions cpp/tests/algo_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@
#include "purify/test_data.h"

using namespace purify;
using namespace purify::notinstalled;

TEST_CASE("padmm_factory") {
const std::string &test_dir = "expected/padmm/";
const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path =
notinstalled::data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path =
notinstalled::data_filename(test_dir + "residual.fits");
const std::string &input_data_path = data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path = data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path = data_filename(test_dir + "residual.fits");

const auto solution = pfitsio::read2d(expected_solution_path);
const auto residual = pfitsio::read2d(expected_residual_path);
Expand Down Expand Up @@ -81,11 +78,9 @@ TEST_CASE("padmm_factory") {
// See https://github.com/astro-informatics/purify/issues/317 for details.
TEST_CASE("primal_dual_factory", "[!shouldfail]") {
const std::string &test_dir = "expected/primal_dual/";
const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path =
notinstalled::data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path =
notinstalled::data_filename(test_dir + "residual.fits");
const std::string &input_data_path = data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path = data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path = data_filename(test_dir + "residual.fits");

const auto solution = pfitsio::read2d(expected_solution_path);
const auto residual = pfitsio::read2d(expected_residual_path);
Expand Down Expand Up @@ -136,12 +131,10 @@ TEST_CASE("primal_dual_factory", "[!shouldfail]") {

TEST_CASE("fb_factory") {
const std::string &test_dir = "expected/fb/";
const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path =
notinstalled::data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path =
notinstalled::data_filename(test_dir + "residual.fits");
const std::string &result_path = notinstalled::data_filename(test_dir + "fb_result.fits");
const std::string &input_data_path = data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path = data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path = data_filename(test_dir + "residual.fits");
const std::string &result_path = data_filename(test_dir + "fb_result.fits");

const auto solution = pfitsio::read2d(expected_solution_path);
const auto residual = pfitsio::read2d(expected_residual_path);
Expand Down Expand Up @@ -192,12 +185,10 @@ TEST_CASE("fb_factory") {
#ifdef PURIFY_ONNXRT
TEST_CASE("tf_fb_factory") {
const std::string &test_dir = "expected/fb/";
const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path =
notinstalled::data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path =
notinstalled::data_filename(test_dir + "residual.fits");
const std::string &result_path = notinstalled::data_filename(test_dir + "tf_result.fits");
const std::string &input_data_path = data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path = data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path = data_filename(test_dir + "residual.fits");
const std::string &result_path = data_filename(test_dir + "tf_result.fits");

const auto solution = pfitsio::read2d(expected_solution_path);
const auto residual = pfitsio::read2d(expected_residual_path);
Expand Down Expand Up @@ -227,8 +218,7 @@ TEST_CASE("tf_fb_factory") {
t_real const beta = sigma * sigma;
t_real const gamma = 0.0001;

std::string tf_model_path =
purify::notinstalled::models_directory() + "/snr_15_model_dynamic.onnx";
std::string tf_model_path = purify::models_directory() + "/snr_15_model_dynamic.onnx";

auto const fb = factory::fb_factory<sopt::algorithm::ImagingForwardBackward<t_complex>>(
factory::algo_distribution::serial, measurements_transform, wavelets, uv_data, sigma, beta,
Expand All @@ -252,12 +242,10 @@ TEST_CASE("tf_fb_factory") {

TEST_CASE("onnx_fb_factory") {
const std::string &test_dir = "expected/fb/";
const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path =
notinstalled::data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path =
notinstalled::data_filename(test_dir + "residual.fits");
const std::string &result_path = notinstalled::data_filename(test_dir + "onnx_result.fits");
const std::string &input_data_path = data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path = data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path = data_filename(test_dir + "residual.fits");
const std::string &result_path = data_filename(test_dir + "onnx_result.fits");
const auto solution = pfitsio::read2d(expected_solution_path);
const auto residual = pfitsio::read2d(expected_residual_path);

Expand Down Expand Up @@ -287,9 +275,9 @@ TEST_CASE("onnx_fb_factory") {
t_real const gamma = 0.0001;

std::string const prior_path =
purify::notinstalled::models_directory() + "/example_cost_dynamic_CRR_sigma_5_t_5.onnx";
purify::models_directory() + "/example_cost_dynamic_CRR_sigma_5_t_5.onnx";
std::string const prior_gradient_path =
purify::notinstalled::models_directory() + "/example_grad_dynamic_CRR_sigma_5_t_5.onnx";
purify::models_directory() + "/example_grad_dynamic_CRR_sigma_5_t_5.onnx";
std::shared_ptr<sopt::ONNXDifferentiableFunc<t_complex>> diff_function =
std::make_shared<sopt::ONNXDifferentiableFunc<t_complex>>(
prior_path, prior_gradient_path, sigma, 20, 5e4, *measurements_transform);
Expand Down Expand Up @@ -317,11 +305,9 @@ TEST_CASE("onnx_fb_factory") {

TEST_CASE("joint_map_factory") {
const std::string &test_dir = "expected/joint_map/";
const std::string &input_data_path = notinstalled::data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path =
notinstalled::data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path =
notinstalled::data_filename(test_dir + "residual.fits");
const std::string &input_data_path = data_filename(test_dir + "input_data.vis");
const std::string &expected_solution_path = data_filename(test_dir + "solution.fits");
const std::string &expected_residual_path = data_filename(test_dir + "residual.fits");

const auto solution = pfitsio::read2d(expected_solution_path);
const auto residual = pfitsio::read2d(expected_residual_path);
Expand Down
1 change: 0 additions & 1 deletion cpp/tests/casacore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "catch2/catch_all.hpp"
namespace casa = casacore;

using namespace purify::notinstalled;
TEST_CASE("Casacore") {
// create the table descriptor
casa::TableDesc simpleDesc = casa::MS::requiredTableDesc();
Expand Down
1 change: 0 additions & 1 deletion cpp/tests/convolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "purify/convolution.h"

using namespace purify;
using namespace purify::notinstalled;

TEST_CASE("1d_zeropad") {
const Vector<t_int> signal = Vector<t_int>::Random(3);
Expand Down
Loading