checkpoint
This commit is contained in:
1 parent
2f87fe31be
commit
d7a12d0dd9
930 files changed
+455
-149078
No files matched your search
+3
-1
@@ -34,7 +34,7 @@ if (WIN32)
|
||||
else ()
|
||||
# so that sparkd looks for libspark.so in its directory
|
||||
set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set (CMAKE_INSTALL_RPATH ".")
|
||||
set (CMAKE_INSTALL_RPATH ".:./lib")
|
||||
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} \
|
||||
-fPIC -Wall -pedantic -Wextra -Werror \
|
||||
@@ -57,6 +57,8 @@ else ()
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/lib/libspark.so ${CMAKE_BINARY_DIR}/server
|
||||
COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/server/plugins
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/sdk/examples/order_plugin_example.so ${CMAKE_BINARY_DIR}/server/plugins/
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/sdk/examples/ai_order_plugin_example.so ${CMAKE_BINARY_DIR}/server/plugins/
|
||||
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/sdk/torch/lib ${CMAKE_BINARY_DIR}/server/lib
|
||||
COMMENT "Creating server runtime layout"
|
||||
DEPENDS sparkd data_files_dir)
|
||||
|
||||
|
||||
+1
-1
Submodule externals updated: eb1b42a5e8...9caeae1761.
@@ -1 +1 @@
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp)
|
||||
set(sources api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/services/AdminService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/cme_reference_data.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/spreader.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;domain_model/SecurityTests.cpp;domain_model/tests/domain_tests.cpp;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPeriodicDumper.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/cme/MDP3Utils.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2ManagedTestHelper.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/catch_test_runner.cpp;utils/AuthToken.cpp;utils/Dispatcher.cpp;utils/GrowableSPSCQueue.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp;utils/stats.cpp;utils/tests/AuthTokenTests.cpp;utils/thread_manager.cpp)
|
||||
@@ -141,4 +141,4 @@ if (WIN32)
|
||||
include(${CMAKE_SOURCE_DIR}/tools/vs_filters.cmake)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
@@ -33,9 +33,10 @@
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
|
||||
// Forked from LibProtobuf for BTS Config by Eric Harding on 5/29/2013
|
||||
// KD disabled warning 4146 on 12/28/2018 to upgrade to proto 3.5
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning (disable: 4273 4800 4018)
|
||||
#pragma warning (disable: 4273 4800 4018 4146)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace orderman {
|
||||
class ChildOrder {
|
||||
public:
|
||||
ChildOrder()
|
||||
: _order(nullptr), _parent_order_services(nullptr), _active(false) {}
|
||||
: _order(nullptr), _parent_order_services(nullptr), _child_order_services(nullptr), _active(false) {}
|
||||
|
||||
ChildOrder(Order &o, OrderServices &services)
|
||||
: _order(&o), _parent_order_services(&services),
|
||||
|
||||
@@ -12,6 +12,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/sdk
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/examples/build_examples.sh
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/examples/md_publisher_example.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/examples/order_plugin_example.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/examples/ai_order_plugin_example.cpp
|
||||
server_layout)
|
||||
|
||||
add_custom_target(sdk_dir ALL DEPENDS ${CMAKE_BINARY_DIR}/sdk)
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
//the pytorch guys were kind enough to #define LOG...
|
||||
#include "torch/script.h"
|
||||
#undef LOG
|
||||
|
||||
#include "spark/lib/logging/logging.h"
|
||||
#include "spark/lib/orderman/orders/DynamicOrder.h"
|
||||
#include "spark/lib/plugin/SparkServices.h"
|
||||
#include "spark/lib/orderman/actors/order_manager/ChildOrder.h"
|
||||
#include "spark/lib/orderman/actors/order_manager/OrderBuilder.h"
|
||||
#include "spark/lib/orderman/orders/DynamicOrder.h"
|
||||
#include "spark/lib/utils/PBUtils.h"
|
||||
#include "lib/config/protos/system.pb.h"
|
||||
#include "lib/config/config.h"
|
||||
|
||||
using namespace bts::api::orderman;
|
||||
using namespace bts::orderman;
|
||||
|
||||
|
||||
namespace bts {
|
||||
namespace order_example {
|
||||
|
||||
class AILeanOrder : public DynamicOrder {
|
||||
public:
|
||||
AILeanOrder();
|
||||
~AILeanOrder();
|
||||
OrderDefinition const &definition() const override;
|
||||
void on_init_new(OrderDefinition const &,
|
||||
const PreActivationOrderServices &) override;
|
||||
void on_init_recovered(OrderRecord const &,
|
||||
const PreActivationOrderServices &) override;
|
||||
void on_activate(Price, Quantity, OrderServices &,
|
||||
trace::CorID const&) override;
|
||||
void on_update(Price, Quantity, trace::CorID const&) override;
|
||||
void on_crack(trace::CorID const &) override;
|
||||
void on_cancel(trace::CorID const &) override;
|
||||
|
||||
private:
|
||||
void report_state();
|
||||
void send_next_child_order();
|
||||
|
||||
void merge_states(OrderState const &iceberg_state,
|
||||
OrderState const &child_state, OrderState *merged);
|
||||
|
||||
void on_child_order_update(OrderStateUpdateEvent const &);
|
||||
void transition(OrderStatus new_state, std::string const &msg);
|
||||
void transition(OrderStatus new_state);
|
||||
|
||||
struct ActiveChild;
|
||||
struct PImpl;
|
||||
std::unique_ptr<PImpl> me;
|
||||
};
|
||||
|
||||
struct AILeanOrder::ActiveChild {
|
||||
ActiveChild() {}
|
||||
ChildOrder order;
|
||||
api::orderman::OrderState state;
|
||||
void clear() { state = api::orderman::OrderState(); }
|
||||
};
|
||||
|
||||
struct AILeanOrder::PImpl {
|
||||
PImpl() : services(nullptr), child() {}
|
||||
|
||||
OrderServices *services;
|
||||
api::orderman::OrderDefinition def;
|
||||
api::orderman::OrderState state;
|
||||
OrderBuilder child_builder;
|
||||
ActiveChild child;
|
||||
Quantity show_quantity;
|
||||
};
|
||||
|
||||
AILeanOrder::AILeanOrder() : me(new PImpl()) {}
|
||||
AILeanOrder::~AILeanOrder() {}
|
||||
api::orderman::OrderDefinition const &AILeanOrder::definition() const {
|
||||
return me->def;
|
||||
}
|
||||
|
||||
void AILeanOrder::on_init_new(
|
||||
api::orderman::OrderDefinition const &def,
|
||||
const PreActivationOrderServices &services) {
|
||||
|
||||
{
|
||||
// Deserialize the ScriptModule from a file using torch::jit::load().
|
||||
std::shared_ptr<torch::jit::script::Module> module = torch::jit::load("");
|
||||
bts_assert(module != nullptr);
|
||||
|
||||
std::vector<torch::jit::IValue> inputs;
|
||||
inputs.push_back(torch::ones({1, 3, 224, 224}));
|
||||
|
||||
// Execute the model and turn its output into a tensor.
|
||||
at::Tensor output = module->forward(inputs).toTensor();
|
||||
|
||||
std::cout << output.slice(/*dim=*/1, /*start=*/0, /*end=*/5) << '\n';
|
||||
}
|
||||
|
||||
me->def = def;
|
||||
me->state.mutable_dynamic();
|
||||
|
||||
auto const &iceberg_def = def.custom_def().dynamic();
|
||||
me->show_quantity =
|
||||
Quantity(iceberg_def.order_params().at("show_size").as_uint32());
|
||||
|
||||
auto child_def = def;
|
||||
*child_def.mutable_custom_def() =
|
||||
iceberg_def.order_params().at("child").as_order_def();
|
||||
if (me->show_quantity.value() != 0) {
|
||||
me->child_builder = OrderBuilder(
|
||||
key(), child_def, services,
|
||||
std::max((size_t)1, (size_t)(me->show_quantity).value() / 10));
|
||||
transition(ORDER_STATUS_INACTIVE);
|
||||
} else {
|
||||
auto msg = fmt::format("Show quantity must be greater than 0");
|
||||
me->state.set_last_msg(msg);
|
||||
transition(ORDER_STATUS_REJECTED_BY_SPARK, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void AILeanOrder::on_init_recovered(
|
||||
api::orderman::OrderRecord const &rec, const PreActivationOrderServices &) {
|
||||
auto const &def = rec.def();
|
||||
me->def = def;
|
||||
me->state = rec.state();
|
||||
|
||||
switch (me->state.status()) {
|
||||
|
||||
case ORDER_STATUS_WORKING:
|
||||
case ORDER_STATUS_DISCONNECTED: {
|
||||
auto msg = "System restarted with active iceberg order";
|
||||
me->state.set_last_msg(msg);
|
||||
transition(ORDER_STATUS_ERROR, msg);
|
||||
break;
|
||||
}
|
||||
// terminal states
|
||||
case ORDER_STATUS_ERROR:
|
||||
case ORDER_STATUS_REJECTED_BY_SPARK:
|
||||
case ORDER_STATUS_COMPLETED:
|
||||
case ORDER_STATUS_CANCELED:
|
||||
break;
|
||||
|
||||
case ORDER_STATUS_PENDING_WORKING:
|
||||
case ORDER_STATUS_INACTIVE:
|
||||
case OrderStatus_INT_MIN_SENTINEL_DO_NOT_USE_:
|
||||
case OrderStatus_INT_MAX_SENTINEL_DO_NOT_USE_:
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AILeanOrder::on_activate(Price p, Quantity q,
|
||||
OrderServices &services,
|
||||
trace::CorID const &) {
|
||||
bts_assert(!me->services);
|
||||
me->services = &services;
|
||||
me->child_builder.activate(services);
|
||||
|
||||
switch (me->state.status()) {
|
||||
case ORDER_STATUS_INACTIVE:
|
||||
me->state.set_price(p.value());
|
||||
me->state.set_quantity(q.value());
|
||||
services.subscribe_to_child_updates(
|
||||
[this](auto const &os) { this->on_child_order_update(os); });
|
||||
transition(ORDER_STATUS_WORKING);
|
||||
send_next_child_order();
|
||||
break;
|
||||
|
||||
// these are not possible since the on_init_recovered code
|
||||
// would have transitioned us to error already
|
||||
case ORDER_STATUS_WORKING:
|
||||
case ORDER_STATUS_PENDING_WORKING:
|
||||
case ORDER_STATUS_DISCONNECTED: {
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
// terminal states
|
||||
case ORDER_STATUS_ERROR:
|
||||
case ORDER_STATUS_REJECTED_BY_SPARK:
|
||||
case ORDER_STATUS_COMPLETED:
|
||||
case ORDER_STATUS_CANCELED:
|
||||
break;
|
||||
case OrderStatus_INT_MIN_SENTINEL_DO_NOT_USE_:
|
||||
case OrderStatus_INT_MAX_SENTINEL_DO_NOT_USE_:
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
report_state();
|
||||
}
|
||||
|
||||
void AILeanOrder::on_update(Price p, Quantity q, trace::CorID const &) {
|
||||
switch (me->state.status()) {
|
||||
case ORDER_STATUS_WORKING:
|
||||
case ORDER_STATUS_PENDING_WORKING:
|
||||
LOG(Plugin, Info,
|
||||
"Updating DynamicIceberg order {} to price {} quantity {}",
|
||||
key().value(), p.value(), q.value());
|
||||
me->state.set_price(p.value());
|
||||
me->state.set_quantity(q.value());
|
||||
break;
|
||||
case ORDER_STATUS_DISCONNECTED:
|
||||
case ORDER_STATUS_REJECTED_BY_SPARK:
|
||||
case ORDER_STATUS_COMPLETED:
|
||||
case ORDER_STATUS_CANCELED:
|
||||
case ORDER_STATUS_ERROR:
|
||||
transition(me->state.status(), "Cannot update order");
|
||||
break;
|
||||
|
||||
case ORDER_STATUS_INACTIVE:
|
||||
case OrderStatus_INT_MIN_SENTINEL_DO_NOT_USE_:
|
||||
case OrderStatus_INT_MAX_SENTINEL_DO_NOT_USE_:
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
report_state();
|
||||
}
|
||||
|
||||
void AILeanOrder::on_crack(trace::CorID const &) {}
|
||||
|
||||
void AILeanOrder::on_cancel(trace::CorID const &) {
|
||||
switch (me->state.status()) {
|
||||
case ORDER_STATUS_WORKING:
|
||||
LOG(Plugin, Info, "Canceling DynamicIceberg Order {}", key().value());
|
||||
me->child.order.cancel();
|
||||
transition(ORDER_STATUS_CANCELED);
|
||||
break;
|
||||
case ORDER_STATUS_PENDING_WORKING:
|
||||
case ORDER_STATUS_DISCONNECTED:
|
||||
case ORDER_STATUS_REJECTED_BY_SPARK:
|
||||
case ORDER_STATUS_COMPLETED:
|
||||
case ORDER_STATUS_CANCELED:
|
||||
case ORDER_STATUS_ERROR:
|
||||
transition(me->state.status(), "Cannot cancel order");
|
||||
break;
|
||||
|
||||
case ORDER_STATUS_INACTIVE:
|
||||
case OrderStatus_INT_MIN_SENTINEL_DO_NOT_USE_:
|
||||
case OrderStatus_INT_MAX_SENTINEL_DO_NOT_USE_:
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
report_state();
|
||||
}
|
||||
|
||||
void AILeanOrder::report_state() {
|
||||
if (me->child.state.filled_quantity()) {
|
||||
api::orderman::OrderState merged_state;
|
||||
merge_states(me->state, me->child.state, &merged_state);
|
||||
me->services->report_state(merged_state);
|
||||
} else
|
||||
me->services->report_state(me->state);
|
||||
}
|
||||
|
||||
void AILeanOrder::merge_states(
|
||||
api::orderman::OrderState const &iceberg_state,
|
||||
api::orderman::OrderState const &child_state,
|
||||
api::orderman::OrderState *merged) {
|
||||
auto child_order_fills = child_state.filled_quantity();
|
||||
auto child_order_avg_price = child_state.avg_price();
|
||||
auto child_order_last_price = child_state.last_price();
|
||||
|
||||
auto iceberg_fills = iceberg_state.filled_quantity();
|
||||
auto iceberg_avg_price = iceberg_state.avg_price();
|
||||
|
||||
*merged = iceberg_state;
|
||||
merged->set_filled_quantity(child_order_fills + iceberg_fills);
|
||||
merged->set_last_price(child_order_last_price);
|
||||
merged->set_avg_price((child_order_fills * child_order_avg_price +
|
||||
iceberg_fills * iceberg_avg_price) /
|
||||
(child_order_fills + iceberg_fills));
|
||||
}
|
||||
|
||||
void AILeanOrder::send_next_child_order() {
|
||||
bts_assert(me->state.quantity() > me->state.filled_quantity());
|
||||
|
||||
auto remaining = me->state.quantity() - me->state.filled_quantity();
|
||||
auto to_send = std::min(remaining, me->show_quantity.value());
|
||||
me->child.order = me->child_builder.build();
|
||||
LOG(Plugin, Info,
|
||||
"DynamicIceberg order {} creating new child order {} with size "
|
||||
"{} price {}. Filled {} so far out of {}",
|
||||
key().value(), me->child.order.key().value(), to_send, me->state.price(),
|
||||
me->state.filled_quantity(), me->state.quantity());
|
||||
|
||||
me->child.order.activate(Price(me->state.price()), Quantity(to_send));
|
||||
}
|
||||
|
||||
void AILeanOrder::on_child_order_update(
|
||||
OrderStateUpdateEvent const &ev) {
|
||||
switch (me->state.status()) {
|
||||
case ORDER_STATUS_WORKING:
|
||||
if (ev.key == me->child.order.key()) {
|
||||
me->child.state = ev.rebuild_state();
|
||||
|
||||
switch (me->child.state.status()) {
|
||||
|
||||
case ORDER_STATUS_WORKING:
|
||||
case ORDER_STATUS_PENDING_WORKING:
|
||||
// nothing to do but report new state
|
||||
break;
|
||||
|
||||
case ORDER_STATUS_COMPLETED: {
|
||||
api::orderman::OrderState merged_state;
|
||||
merge_states(me->state, me->child.state, &merged_state);
|
||||
me->state = merged_state;
|
||||
me->child.clear();
|
||||
if (me->state.quantity() > me->state.filled_quantity())
|
||||
send_next_child_order();
|
||||
else
|
||||
transition(ORDER_STATUS_COMPLETED);
|
||||
break;
|
||||
}
|
||||
|
||||
case ORDER_STATUS_CANCELED:
|
||||
LOG(Plugin, Info,
|
||||
"Unexpected cancel of child {} in DynamicIceberg Order {}. "
|
||||
"Canceling parent",
|
||||
ev.key.value(), key().value());
|
||||
transition(ORDER_STATUS_CANCELED);
|
||||
break;
|
||||
|
||||
case ORDER_STATUS_DISCONNECTED:
|
||||
case ORDER_STATUS_REJECTED_BY_SPARK:
|
||||
case ORDER_STATUS_ERROR:
|
||||
me->child.clear();
|
||||
transition(ORDER_STATUS_ERROR, "Unexpected child order state");
|
||||
break;
|
||||
|
||||
case ORDER_STATUS_INACTIVE:
|
||||
case OrderStatus_INT_MIN_SENTINEL_DO_NOT_USE_:
|
||||
case OrderStatus_INT_MAX_SENTINEL_DO_NOT_USE_:
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
LOG(Plugin, Info,
|
||||
"DynamicIceberg order {} received update for non active child "
|
||||
"order{} . update state = {} ",
|
||||
key().value(), me->child.order.key().value(),
|
||||
utils::pb::to_string(ev.rebuild_state()));
|
||||
}
|
||||
break;
|
||||
|
||||
case ORDER_STATUS_CANCELED:
|
||||
case ORDER_STATUS_ERROR:
|
||||
case ORDER_STATUS_DISCONNECTED:
|
||||
case ORDER_STATUS_COMPLETED:
|
||||
break;
|
||||
|
||||
case ORDER_STATUS_PENDING_WORKING:
|
||||
case ORDER_STATUS_REJECTED_BY_SPARK:
|
||||
case ORDER_STATUS_INACTIVE:
|
||||
case OrderStatus_INT_MIN_SENTINEL_DO_NOT_USE_:
|
||||
case OrderStatus_INT_MAX_SENTINEL_DO_NOT_USE_:
|
||||
bts_assert(false);
|
||||
break;
|
||||
}
|
||||
report_state();
|
||||
}
|
||||
|
||||
void AILeanOrder::transition(api::orderman::OrderStatus new_status,
|
||||
std::string const &msg) {
|
||||
auto const &from = OrderStatus_Name(me->state.status());
|
||||
auto const &to = OrderStatus_Name(new_status);
|
||||
LOG(Plugin, Info,
|
||||
"Transitioning dynamic iceberg order {} from {} to {}. Msg: {}",
|
||||
key().value(), from, to, msg);
|
||||
me->state.set_last_msg(msg);
|
||||
me->state.set_status(new_status);
|
||||
}
|
||||
|
||||
void AILeanOrder::transition(api::orderman::OrderStatus new_status) {
|
||||
auto const &from = OrderStatus_Name(me->state.status());
|
||||
auto const &to = OrderStatus_Name(new_status);
|
||||
LOG(OrderMan, Info, "Transitioning dynamic iceberg order {} from {} to {}",
|
||||
key().value(), from, to);
|
||||
me->state.set_status(new_status);
|
||||
}
|
||||
|
||||
|
||||
} // namespace order_example
|
||||
} // namespace bts
|
||||
|
||||
DynamicOrderDescriptor get_order_desc()
|
||||
{
|
||||
DynamicOrderDescriptor desc;
|
||||
|
||||
// order type name
|
||||
desc.set_dynamic_order_type("AILeanOrder");
|
||||
|
||||
// show size
|
||||
auto param = desc.add_param_desc();
|
||||
param->set_param_name("show_size");
|
||||
param->mutable_param_type()->set_primitive(DYNAMIC_ORDER_PRIMITIVE_UINT);
|
||||
|
||||
// child order
|
||||
param = desc.add_param_desc();
|
||||
param->set_param_name("child");
|
||||
param->mutable_param_type()->set_primitive(DYNAMIC_ORDER_PRIMITIVE_ORDER_DEF);
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
extern "C" void init_spark_plugin(bts::SparkServices &serv) {
|
||||
using namespace bts;
|
||||
|
||||
if (config::get<config::DeploymentType>().type() == "dev") {
|
||||
serv.register_dynamic_order(get_order_desc(),
|
||||
[]() { return std::make_unique<bts::order_example::AILeanOrder>(); });
|
||||
LOG(Plugin,Info, "Initialized ai_order_plugin_example.so");
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,32 @@ g++ -isystem ../externals/include \
|
||||
-llttng-ust \
|
||||
-ldl
|
||||
|
||||
|
||||
|
||||
if [ -d "./../../../../../torch/" ]; then
|
||||
|
||||
g++ -isystem ../externals/include \
|
||||
-I ../include \
|
||||
-I ../include/spark \
|
||||
-I ../torch/include \
|
||||
-std=c++1z \
|
||||
-fPIC \
|
||||
-g \
|
||||
-shared \
|
||||
-o ai_order_plugin_example.so \
|
||||
ai_order_plugin_example.cpp \
|
||||
-Wl,-rpath,.. \
|
||||
-Wl,-rpath,./lib \
|
||||
-Wl,-rpath,../lib \
|
||||
-L ../lib \
|
||||
-l spark \
|
||||
-L ../torch/lib \
|
||||
-l torch
|
||||
else
|
||||
|
||||
g++ -isystem ../externals/include \
|
||||
-I ../include \
|
||||
-I ../include/spark \
|
||||
-I ../include/mlpack \
|
||||
-std=c++1z \
|
||||
-fPIC \
|
||||
-g \
|
||||
@@ -23,8 +45,7 @@ g++ -isystem ../externals/include \
|
||||
-o order_plugin_example.so \
|
||||
order_plugin_example.cpp \
|
||||
-Wl,-rpath,.. \
|
||||
-L ../lib \
|
||||
-l spark \
|
||||
-L ../mlpack/lib \
|
||||
-l mlpack \
|
||||
-fopenmp
|
||||
-L ../lib \
|
||||
-l spark
|
||||
|
||||
fi
|
||||
@@ -11,21 +11,6 @@
|
||||
using namespace bts::api::orderman;
|
||||
using namespace bts::orderman;
|
||||
|
||||
|
||||
#include "mlpack/core.hpp"
|
||||
#include "mlpack/methods/random_forest/random_forest.hpp"
|
||||
#include "mlpack/methods/decision_tree/random_dimension_select.hpp"
|
||||
#include "mlpack/core/cv/k_fold_cv.hpp"
|
||||
#include "mlpack/core/cv/metrics/accuracy.hpp"
|
||||
#include "mlpack/core/cv/metrics/precision.hpp"
|
||||
#include "mlpack/core/cv/metrics/recall.hpp"
|
||||
//#include "mlpack/core/cv/metrics/F1.hpp"
|
||||
|
||||
using namespace arma;
|
||||
using namespace mlpack;
|
||||
using namespace mlpack::tree;
|
||||
using namespace mlpack::cv;
|
||||
|
||||
namespace bts {
|
||||
namespace order_example {
|
||||
|
||||
@@ -87,27 +72,6 @@ api::orderman::OrderDefinition const &DynamicIcebergOrder::definition() const {
|
||||
void DynamicIcebergOrder::on_init_new(
|
||||
api::orderman::OrderDefinition const &def,
|
||||
const PreActivationOrderServices &services) {
|
||||
|
||||
{
|
||||
mat dataset;
|
||||
|
||||
mlpack::data::Load("data/german.csv", dataset);
|
||||
|
||||
Row<size_t> labels;
|
||||
labels = conv_to<Row<size_t>>::from(dataset.row(dataset.n_rows - 1));
|
||||
dataset.shed_row(dataset.n_rows - 1);
|
||||
const size_t numClasses = 2;
|
||||
const size_t minimumLeafSize = 5;
|
||||
const size_t numTrees = 10;
|
||||
RandomForest<GiniGain, RandomDimensionSelect> rf;
|
||||
rf = RandomForest<GiniGain, RandomDimensionSelect>(dataset, labels,
|
||||
numClasses, numTrees, minimumLeafSize);
|
||||
|
||||
Row<size_t> predictions;
|
||||
rf.Classify(dataset, predictions);
|
||||
const size_t correct = arma::accu(predictions == labels);
|
||||
cout << "\nTraining Accuracy: " << (double(correct) / double(labels.n_elem));
|
||||
}
|
||||
|
||||
me->def = def;
|
||||
me->state.mutable_dynamic();
|
||||
|
||||
+6
-5
@@ -26,11 +26,12 @@ ln -sf $1/server $1/sdk/lib
|
||||
mkdir $1/sdk/examples
|
||||
cp $2/examples/* $1/sdk/examples
|
||||
|
||||
ln -sf $2/mlpack $1/sdk/mlpack
|
||||
ln -sf $2/mlpack/include $1/sdk/include/mlpack
|
||||
#mkdir $1/sdk/mlpack
|
||||
#cp -r $2/mlpack/* $1/sdk/mlpack
|
||||
#cp -r $2/mlpack/include/* $1/sdk/include
|
||||
#torch is outside the spark repo, I didn't want to force a subrepo just yet
|
||||
if [ -d "$2/../../../torch/" ]; then
|
||||
mkdir -p $1/sdk/torch/
|
||||
ln -sf $2/../../../torch/linux/include $1/sdk/torch/include
|
||||
ln -sf $2/../../../torch/linux/lib $1/sdk/torch/lib
|
||||
fi
|
||||
|
||||
cp $2/sdk_shell.sh $1/sdk/sdk_shell.sh
|
||||
cp $2/update_github.sh $1/sdk/update_github.sh
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,1000 +0,0 @@
|
||||
1,6,4,12,5,5,3,4,1,67,3,2,1,2,1,0,0,1,0,0,1,0,0,1
|
||||
2,48,2,60,1,3,2,2,1,22,3,1,1,1,1,0,0,1,0,0,1,0,0,1
|
||||
4,12,4,21,1,4,3,3,1,49,3,1,2,1,1,0,0,1,0,0,1,0,1,0
|
||||
1,42,2,79,1,4,3,4,2,45,3,1,2,1,1,0,0,0,0,0,0,0,0,1
|
||||
1,24,3,49,1,3,3,4,4,53,3,2,2,1,1,1,0,1,0,0,0,0,0,1
|
||||
4,36,2,91,5,3,3,4,4,35,3,1,2,2,1,0,0,1,0,0,0,0,1,0
|
||||
4,24,2,28,3,5,3,4,2,53,3,1,1,1,1,0,0,1,0,0,1,0,0,1
|
||||
2,36,2,69,1,3,3,2,3,35,3,1,1,2,1,0,1,1,0,1,0,0,0,0
|
||||
4,12,2,31,4,4,1,4,1,61,3,1,1,1,1,0,0,1,0,0,1,0,1,0
|
||||
2,30,4,52,1,1,4,2,3,28,3,2,1,1,1,1,0,1,0,0,1,0,0,0
|
||||
2,12,2,13,1,2,2,1,3,25,3,1,1,1,1,1,0,1,0,1,0,0,0,1
|
||||
1,48,2,43,1,2,2,4,2,24,3,1,1,1,1,0,0,1,0,1,0,0,0,1
|
||||
2,12,2,16,1,3,2,1,3,22,3,1,1,2,1,0,0,1,0,0,1,0,0,1
|
||||
1,24,4,12,1,5,3,4,3,60,3,2,1,1,1,1,0,1,0,0,1,0,1,0
|
||||
1,15,2,14,1,3,2,4,3,28,3,1,1,1,1,1,0,1,0,1,0,0,0,1
|
||||
1,24,2,13,2,3,2,2,3,32,3,1,1,1,1,0,0,1,0,0,1,0,1,0
|
||||
4,24,4,24,5,5,3,4,2,53,3,2,1,1,1,0,0,1,0,0,1,0,0,1
|
||||
1,30,0,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1,3,3,2,2,26,3,1,2,1,1,0,1,1,0,0,1,0,0,1
|
||||
4,24,4,20,1,4,3,2,2,30,3,2,1,1,1,0,0,1,0,0,1,0,1,0
|
||||
1,15,4,14,1,3,2,3,2,25,3,2,1,1,1,0,0,1,0,1,0,0,0,1
|
||||
3,42,0,63,1,2,1,1,2,33,3,2,1,1,1,0,0,1,0,0,1,0,0,1
|
||||
4,13,2,14,2,1,2,4,1,64,3,1,1,1,1,0,0,1,0,0,1,0,0,1
|
||||
1,24,2,66,1,1,3,2,4,29,3,1,1,2,1,0,1,1,0,0,0,0,0,0
|
||||
2,24,4,17,1,5,3,2,2,48,3,2,1,1,1,0,0,1,0,0,1,0,1,0
|
||||
4,12,4,36,5,2,3,1,2,37,3,2,2,1,1,0,0,1,0,0,1,0,1,0
|
||||
4,15,1,16,2,5,3,4,3,34,1,1,2,1,1,0,0,1,0,0,1,0,1,0
|
||||
1,18,2,19,5,4,4,4,3,23,3,2,1,1,1,0,0,1,0,1,0,0,1,0
|
||||
1,36,2,40,1,1,3,3,2,30,3,1,1,2,1,0,0,1,0,0,1,0,0,0
|
||||
4,12,2,24,5,5,3,3,3,50,3,1,1,2,1,1,0,1,0,0,1,0,0,1
|
||||
4,12,2,17,1,4,2,4,1,31,3,1,1,1,1,0,0,1,0,0,1,0,1,0
|
||||
1,30,2,39,1,3,1,4,2,40,3,1,1,2,1,0,1,1,0,0,1,0,0,0
|
||||
4,12,2,8,1,5,3,4,3,38,3,1,1,1,1,0,0,1,0,0,1,0,0,1
|
||||
1,45,2,18,1,3,3,4,4,23,3,1,1,2,1,0,0,1,0,0,0,0,0,1
|
||||
2,45,4,46,2,1,3,4,3,27,3,1,1,1,1,0,1,1,0,0,1,0,0,1
|
||||
|
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* @file add_to_po.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Utility functions to add options to boost::program_options based on their
|
||||
* type.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_ADD_TO_PO_HPP
|
||||
#define MLPACK_BINDINGS_CLI_ADD_TO_PO_HPP
|
||||
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <mlpack/core/util/is_std_vector.hpp>
|
||||
#include "map_parameter_name.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Add a non-vector option to boost::program_options.
|
||||
*
|
||||
* @param boostName The name of the option to add to boost::program_options.
|
||||
* @param descr Description string for parameter.
|
||||
* @param desc Options description to add parameter to.
|
||||
*/
|
||||
template<typename T>
|
||||
void AddToPO(const std::string& boostName,
|
||||
const std::string& descr,
|
||||
boost::program_options::options_description& desc,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T, bool>>::type* = 0)
|
||||
{
|
||||
desc.add_options()(boostName.c_str(), boost::program_options::value<T>(),
|
||||
descr.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a vector option to boost::program_options. This overload will use the
|
||||
* multitoken() option.
|
||||
*
|
||||
* @param boostName The name of the option to add to boost::program_options.
|
||||
* @param descr Description string for parameter.
|
||||
* @param desc Options description to add parameter to.
|
||||
*/
|
||||
template<typename T>
|
||||
void AddToPO(const std::string& boostName,
|
||||
const std::string& descr,
|
||||
boost::program_options::options_description& desc,
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T, bool>>::type* = 0)
|
||||
{
|
||||
desc.add_options()(boostName.c_str(),
|
||||
boost::program_options::value<T>()->multitoken(), descr.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a boolean option to boost::program_options.
|
||||
*
|
||||
* @param boostName The name of the option to add to boost::program_options.
|
||||
* @param descr Description string for parameter.
|
||||
* @param desc Options description to add parameter to.
|
||||
*/
|
||||
template<typename T>
|
||||
void AddToPO(const std::string& boostName,
|
||||
const std::string& descr,
|
||||
boost::program_options::options_description& desc,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::enable_if<std::is_same<T, bool>>::type* = 0)
|
||||
{
|
||||
desc.add_options()(boostName.c_str(), descr.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an option to boost::program_options. This is the function meant to be
|
||||
* used in the CLI function map.
|
||||
*
|
||||
* @param d Parameter data.
|
||||
* @param input Unused void pointer.
|
||||
* @param output Void pointer to options_description object.
|
||||
*/
|
||||
template<typename T>
|
||||
void AddToPO(const util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
// Cast boost::program_options::options_description object.
|
||||
boost::program_options::options_description* desc =
|
||||
(boost::program_options::options_description*) output;
|
||||
|
||||
// Generate the name to be given to boost::program_options.
|
||||
const std::string mappedName =
|
||||
MapParameterName<typename std::remove_pointer<T>::type>(d.name);
|
||||
std::string boostName = (d.alias != '\0') ? mappedName + "," +
|
||||
std::string(1, d.alias) : mappedName;
|
||||
|
||||
// Note that we have to add the option as type equal to the mapped type, not
|
||||
// the true type of the option.
|
||||
AddToPO<typename ParameterType<typename std::remove_pointer<T>::type>::type>(
|
||||
boostName, d.desc, *desc);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,199 +0,0 @@
|
||||
/**
|
||||
* @file option.hpp
|
||||
* @author Matthew Amidon
|
||||
*
|
||||
* Definition of the Option class, which is used to define parameters which are
|
||||
* used by CLI. The ProgramDoc class also resides here.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_CORE_BINDINGS_CLI_CLI_OPTION_HPP
|
||||
#define MLPACK_CORE_BINDINGS_CLI_CLI_OPTION_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <mlpack/core/util/cli.hpp>
|
||||
#include "parameter_type.hpp"
|
||||
#include "add_to_po.hpp"
|
||||
#include "default_param.hpp"
|
||||
#include "output_param.hpp"
|
||||
#include "get_printable_param.hpp"
|
||||
#include "string_type_param.hpp"
|
||||
#include "get_param.hpp"
|
||||
#include "get_raw_param.hpp"
|
||||
#include "map_parameter_name.hpp"
|
||||
#include "set_param.hpp"
|
||||
#include "get_printable_param_name.hpp"
|
||||
#include "get_printable_param_value.hpp"
|
||||
#include "get_allocated_memory.hpp"
|
||||
#include "delete_allocated_memory.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* A static object whose constructor registers a parameter with the CLI class.
|
||||
* This should not be used outside of CLI itself, and you should use the
|
||||
* PARAM_FLAG(), PARAM_DOUBLE(), PARAM_INT(), PARAM_STRING(), or other similar
|
||||
* macros to declare these objects instead of declaring them directly.
|
||||
*
|
||||
* @see core/util/cli.hpp, mlpack::CLI
|
||||
*/
|
||||
template<typename N>
|
||||
class CLIOption
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct an Option object. When constructed, it will register
|
||||
* itself with CLI.
|
||||
*
|
||||
* @param defaultValue Default value this parameter will be initialized to
|
||||
* (for flags, this should be false, for instance).
|
||||
* @param identifier The name of the option (no dashes in front; for --help,
|
||||
* we would pass "help").
|
||||
* @param description A short string describing the option.
|
||||
* @param alias Short name of the parameter. "" for no alias.
|
||||
* @param cppName Name of the C++ type of this parameter (i.e. "int").
|
||||
* @param required Whether or not the option is required at runtime.
|
||||
* @param input Whether or not the option is an input option.
|
||||
* @param noTranspose If the parameter is a matrix and this is true, then the
|
||||
* matrix will not be transposed on loading.
|
||||
* @param testName Is not used and added for compatibility reasons.
|
||||
*/
|
||||
CLIOption(const N defaultValue,
|
||||
const std::string& identifier,
|
||||
const std::string& description,
|
||||
const std::string& alias,
|
||||
const std::string& cppName,
|
||||
const bool required = false,
|
||||
const bool input = true,
|
||||
const bool noTranspose = false,
|
||||
const std::string& /*testName*/ = "")
|
||||
{
|
||||
// Create the ParamData object to give to CLI.
|
||||
util::ParamData data;
|
||||
|
||||
data.desc = description;
|
||||
data.name = identifier;
|
||||
data.tname = TYPENAME(N);
|
||||
data.alias = alias[0];
|
||||
data.wasPassed = false;
|
||||
data.noTranspose = noTranspose;
|
||||
data.required = required;
|
||||
data.input = input;
|
||||
data.loaded = false;
|
||||
data.persistent = false; // All CLI parameters are not persistent.
|
||||
data.cppType = cppName;
|
||||
|
||||
// Apply default value.
|
||||
if (std::is_same<typename std::remove_pointer<N>::type,
|
||||
typename ParameterType<typename
|
||||
std::remove_pointer<N>::type>::type>::value)
|
||||
{
|
||||
data.value = boost::any(defaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
typename ParameterType<typename std::remove_pointer<N>::type>::type tmp;
|
||||
data.value = boost::any(std::tuple<N, decltype(tmp)>(defaultValue, tmp));
|
||||
}
|
||||
|
||||
const std::string tname = data.tname;
|
||||
const std::string boostName = MapParameterName<
|
||||
typename std::remove_pointer<N>::type>(identifier);
|
||||
std::string progOptId = (alias[0] != '\0') ? boostName + ","
|
||||
+ std::string(1, alias[0]) : boostName;
|
||||
|
||||
// Do a check to ensure that the boost name isn't already in use.
|
||||
const std::map<std::string, util::ParamData>& parameters =
|
||||
CLI::Parameters();
|
||||
if (parameters.count(boostName) > 0)
|
||||
{
|
||||
// Create a fake Log::Fatal since it may not yet be initialized.
|
||||
// Temporarily define color code escape sequences.
|
||||
#ifndef _WIN32
|
||||
#define BASH_RED "\033[0;31m"
|
||||
#define BASH_CLEAR "\033[0m"
|
||||
#else
|
||||
#define BASH_RED ""
|
||||
#define BASH_CLEAR ""
|
||||
#endif
|
||||
|
||||
// Temporary outstream object for detecting duplicate identifiers.
|
||||
util::PrefixedOutStream outstr(std::cerr,
|
||||
BASH_RED "[FATAL] " BASH_CLEAR, false, true /* fatal */);
|
||||
|
||||
#undef BASH_RED
|
||||
#undef BASH_CLEAR
|
||||
|
||||
outstr << "Parameter --" << boostName << " (" << data.alias << ") "
|
||||
<< "is defined multiple times with the same identifiers."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
CLI::Add(std::move(data));
|
||||
|
||||
// Set some function pointers that we need.
|
||||
CLI::GetSingleton().functionMap[tname]["DefaultParam"] =
|
||||
&DefaultParam<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["OutputParam"] =
|
||||
&OutputParam<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["GetPrintableParam"] =
|
||||
&GetPrintableParam<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["StringTypeParam"] =
|
||||
&StringTypeParam<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["GetParam"] = &GetParam<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["GetRawParam"] = &GetRawParam<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["AddToPO"] = &AddToPO<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["MapParameterName"] =
|
||||
&MapParameterName<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["SetParam"] = &SetParam<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["GetPrintableParamName"] =
|
||||
&GetPrintableParamName<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["GetPrintableParamValue"] =
|
||||
&GetPrintableParamValue<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["GetAllocatedMemory"] =
|
||||
&GetAllocatedMemory<N>;
|
||||
CLI::GetSingleton().functionMap[tname]["DeleteAllocatedMemory"] =
|
||||
&DeleteAllocatedMemory<N>;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A static object whose constructor registers program documentation with the
|
||||
* CLI class. This should not be used outside of CLI itself, and you should use
|
||||
* the PROGRAM_INFO() macro to declare these objects. Only one ProgramDoc
|
||||
* object should ever exist.
|
||||
*
|
||||
* @see core/util/cli.hpp, mlpack::CLI
|
||||
*/
|
||||
class ProgramDoc
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a ProgramDoc object. When constructed, it will register itself
|
||||
* with CLI.
|
||||
*
|
||||
* @param programName Short string representing the name of the program.
|
||||
* @param documentation Long string containing documentation on how to use the
|
||||
* program and what it is. No newline characters are necessary; this is
|
||||
* taken care of by CLI later.
|
||||
*/
|
||||
ProgramDoc(const std::string& programName,
|
||||
const std::string& documentation);
|
||||
|
||||
//! The name of the program.
|
||||
std::string programName;
|
||||
//! Documentation for what the program does.
|
||||
std::string documentation;
|
||||
};
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,95 +0,0 @@
|
||||
/**
|
||||
* @file default_param.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Return the default value of a parameter, depending on its type.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_DEFAULT_PARAM_HPP
|
||||
#define MLPACK_BINDINGS_CLI_DEFAULT_PARAM_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
#include <mlpack/core/util/is_std_vector.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Return the default value of an option. This is for regular types.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T, std::string>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a vector option.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a string option.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<std::is_same<T, std::string>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a matrix option, a tuple option, a
|
||||
* serializable option, or a string option (this returns the default filename,
|
||||
* or '' if the default is no file).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if_c<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* /* junk */ = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of a model option (this returns the default
|
||||
* filename, or '' if the default is no file).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Return the default value of an option. This is the function that will be
|
||||
* placed into the CLI functionMap.
|
||||
*/
|
||||
template<typename T>
|
||||
void DefaultParam(const util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = DefaultParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation.
|
||||
#include "default_param_impl.hpp"
|
||||
|
||||
#endif
|
||||
@@ -1,110 +0,0 @@
|
||||
/**
|
||||
* @file default_param_impl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Return the default value of a parameter, depending on its type.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_DEFAULT_PARAM_IMPL_HPP
|
||||
#define MLPACK_BINDINGS_CLI_DEFAULT_PARAM_IMPL_HPP
|
||||
|
||||
#include "default_param.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Return the default value of an option.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<std::is_same<T, std::string>>::type*,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* /* junk */)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << boost::any_cast<T>(data.value);
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of a vector option.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
|
||||
{
|
||||
// Print each element in an array delimited by square brackets.
|
||||
std::ostringstream oss;
|
||||
const T& vector = boost::any_cast<T>(data.value);
|
||||
oss << "[";
|
||||
for (size_t i = 0; i < vector.size() - 1; ++i)
|
||||
oss << vector[i] << " ";
|
||||
oss << vector[vector.size() - 1] << "]";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of a string option.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<std::is_same<T, std::string>>::type*)
|
||||
{
|
||||
const std::string& s = *boost::any_cast<std::string>(&data.value);
|
||||
return "'" + s + "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of a matrix option (this returns the default
|
||||
* filename, or '' if the default is no file).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if_c<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* /* junk */)
|
||||
{
|
||||
// Get the filename and return it, or return an empty string.
|
||||
typedef std::tuple<T, std::string> TupleType;
|
||||
const TupleType& tuple = *boost::any_cast<TupleType>(&data.value);
|
||||
const std::string& filename = std::get<1>(tuple);
|
||||
return "'" + filename + "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of a model option (this returns the default
|
||||
* filename, or '' if the default is no file).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string DefaultParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
|
||||
{
|
||||
// Get the filename and return it, or return an empty string.
|
||||
typedef std::tuple<T*, std::string> TupleType;
|
||||
const TupleType& tuple = *boost::any_cast<TupleType>(&data.value);
|
||||
const std::string& filename = std::get<1>(tuple);
|
||||
return "'" + filename + "'";
|
||||
}
|
||||
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,62 +0,0 @@
|
||||
/**
|
||||
* @file delete_allocated_memory.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* If any memory has been allocated by the parameter, delete it.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_DELETE_ALLOCATED_MEMORY_HPP
|
||||
#define MLPACK_BINDINGS_CLI_DELETE_ALLOCATED_MEMORY_HPP
|
||||
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
template<typename T>
|
||||
void DeleteAllocatedMemoryImpl(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void DeleteAllocatedMemoryImpl(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void DeleteAllocatedMemoryImpl(
|
||||
const util::ParamData& d,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// Delete the allocated memory (hopefully we actually own it).
|
||||
typedef std::tuple<T*, std::string> TupleType;
|
||||
delete std::get<0>(*boost::any_cast<TupleType>(&d.value));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void DeleteAllocatedMemory(
|
||||
const util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
DeleteAllocatedMemoryImpl<typename std::remove_pointer<T>::type>(d);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* @file end_program.hpp
|
||||
* @author Ryan Curtin
|
||||
* @author Matthew Amidon
|
||||
*
|
||||
* Terminate the program; handle --verbose option; print output parameters.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_END_PROGRAM_HPP
|
||||
#define MLPACK_BINDINGS_CLI_END_PROGRAM_HPP
|
||||
|
||||
#include <mlpack/core/util/cli.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Handle command-line program termination. If --help or --info was passed, we
|
||||
* won't make it here, so we don't have to write any contingencies for that.
|
||||
*/
|
||||
inline void EndProgram()
|
||||
{
|
||||
// Stop the CLI timers.
|
||||
CLI::GetSingleton().timer.StopAllTimers();
|
||||
|
||||
// Print any output.
|
||||
const std::map<std::string, util::ParamData>& parameters = CLI::Parameters();
|
||||
std::map<std::string, util::ParamData>::const_iterator it =
|
||||
parameters.begin();
|
||||
while (it != parameters.end())
|
||||
{
|
||||
const util::ParamData& d = it->second;
|
||||
if (!d.input)
|
||||
CLI::GetSingleton().functionMap[d.tname]["OutputParam"](d, NULL, NULL);
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
if (CLI::HasParam("verbose"))
|
||||
{
|
||||
Log::Info << std::endl << "Execution parameters:" << std::endl;
|
||||
|
||||
// Print out all the values.
|
||||
it = parameters.begin();
|
||||
while (it != parameters.end())
|
||||
{
|
||||
// Now, figure out what type it is, and print it.
|
||||
// We can handle strings, ints, bools, floats, doubles.
|
||||
const util::ParamData& data = it->second;
|
||||
std::string boostName;
|
||||
CLI::GetSingleton().functionMap[data.tname]["MapParameterName"](data,
|
||||
NULL, (void*) &boostName);
|
||||
Log::Info << " " << boostName << ": ";
|
||||
|
||||
std::string printableParam;
|
||||
CLI::GetSingleton().functionMap[data.tname]["GetPrintableParam"](data,
|
||||
NULL, (void*) &printableParam);
|
||||
Log::Info << printableParam << std::endl;
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
Log::Info << "Program timers:" << std::endl;
|
||||
for (auto it2 : CLI::GetSingleton().timer.GetAllTimers())
|
||||
{
|
||||
Log::Info << " " << it2.first << ": ";
|
||||
CLI::GetSingleton().timer.PrintTimer(it2.first);
|
||||
}
|
||||
}
|
||||
|
||||
// Lastly clean up any memory. If we are holding any pointers, then we "own"
|
||||
// them. But we may hold the same pointer twice, so we have to be careful to
|
||||
// not delete it multiple times.
|
||||
std::unordered_map<void*, const util::ParamData*> memoryAddresses;
|
||||
it = parameters.begin();
|
||||
while (it != parameters.end())
|
||||
{
|
||||
const util::ParamData& data = it->second;
|
||||
|
||||
void* result;
|
||||
CLI::GetSingleton().functionMap[data.tname]["GetAllocatedMemory"](data,
|
||||
NULL, (void*) &result);
|
||||
if (result != NULL && memoryAddresses.count(result) == 0)
|
||||
memoryAddresses[result] = &data;
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
// Now we have all the unique addresses that need to be deleted.
|
||||
std::unordered_map<void*, const util::ParamData*>::const_iterator it2;
|
||||
it2 = memoryAddresses.begin();
|
||||
while (it2 != memoryAddresses.end())
|
||||
{
|
||||
const util::ParamData& data = *(it2->second);
|
||||
|
||||
CLI::GetSingleton().functionMap[data.tname]["DeleteAllocatedMemory"](data,
|
||||
NULL, NULL);
|
||||
|
||||
++it2;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* @file get_allocated_memory.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* If the parameter has a type that may need to be deleted, return the address
|
||||
* of that object. Otherwise return NULL.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_GET_ALLOCATED_MEMORY_HPP
|
||||
#define MLPACK_BINDINGS_CLI_GET_ALLOCATED_MEMORY_HPP
|
||||
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
template<typename T>
|
||||
void* GetAllocatedMemory(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void* GetAllocatedMemory(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void* GetAllocatedMemory(
|
||||
const util::ParamData& d,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// Here we have a model, which is a tuple, and we need the address of the
|
||||
// memory.
|
||||
typedef std::tuple<T*, std::string> TupleType;
|
||||
return std::get<0>(*boost::any_cast<TupleType>(&d.value));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void GetAllocatedMemory(const util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((void**) output) =
|
||||
GetAllocatedMemory<typename std::remove_pointer<T>::type>(d);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,143 +0,0 @@
|
||||
/**
|
||||
* @file get_param.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Use template metaprogramming to get the right type of parameter.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_GET_PARAM_HPP
|
||||
#define MLPACK_BINDINGS_CLI_GET_PARAM_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include "parameter_type.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* This overload is called when nothing special needs to happen to the name of
|
||||
* the parameter.
|
||||
*
|
||||
* @param d ParamData object to get parameter value from.
|
||||
*/
|
||||
template<typename T>
|
||||
T& GetParam(
|
||||
util::ParamData& d,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
// No mapping is needed, so just cast it directly.
|
||||
return *boost::any_cast<T>(&d.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a matrix parameter.
|
||||
*
|
||||
* @param d ParamData object to get parameter value from.
|
||||
*/
|
||||
template<typename T>
|
||||
T& GetParam(
|
||||
util::ParamData& d,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
// If the matrix is an input matrix, we have to load the matrix. 'value'
|
||||
// contains the filename. It's possible we could load empty matrices many
|
||||
// times, but I am not bothered by that---it shouldn't be something that
|
||||
// happens.
|
||||
typedef std::tuple<T, typename ParameterType<T>::type> TupleType;
|
||||
TupleType& tuple = *boost::any_cast<TupleType>(&d.value);
|
||||
const std::string& value = std::get<1>(tuple);
|
||||
T& matrix = std::get<0>(tuple);
|
||||
if (d.input && !d.loaded)
|
||||
{
|
||||
// Call correct data::Load() function.
|
||||
if (arma::is_Row<T>::value || arma::is_Col<T>::value)
|
||||
data::Load(value, matrix, true);
|
||||
else
|
||||
data::Load(value, matrix, true, !d.noTranspose);
|
||||
d.loaded = true;
|
||||
}
|
||||
|
||||
return matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a matrix/dataset info parameter.
|
||||
*
|
||||
* @param d ParamData object to get parameter value from.
|
||||
*/
|
||||
template<typename T>
|
||||
T& GetParam(
|
||||
util::ParamData& d,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
// If this is an input parameter, we need to load both the matrix and the
|
||||
// dataset info.
|
||||
typedef std::tuple<T, std::string> TupleType;
|
||||
TupleType* tuple = boost::any_cast<TupleType>(&d.value);
|
||||
const std::string& value = std::get<1>(*tuple);
|
||||
T& t = std::get<0>(*tuple);
|
||||
if (d.input && !d.loaded)
|
||||
{
|
||||
data::Load(value, std::get<1>(t), std::get<0>(t), true, !d.noTranspose);
|
||||
d.loaded = true;
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a serializable object.
|
||||
*
|
||||
* @param d ParamData object to get parameter value from.
|
||||
*/
|
||||
template<typename T>
|
||||
T*& GetParam(
|
||||
util::ParamData& d,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// If the model is an input model, we have to load it from file. 'value'
|
||||
// contains the filename.
|
||||
typedef std::tuple<T*, std::string> TupleType;
|
||||
TupleType* tuple = boost::any_cast<TupleType>(&d.value);
|
||||
const std::string& value = std::get<1>(*tuple);
|
||||
if (d.input && !d.loaded)
|
||||
{
|
||||
T* model = new T();
|
||||
data::Load(value, "model", *model, true);
|
||||
d.loaded = true;
|
||||
std::get<0>(*tuple) = model;
|
||||
}
|
||||
return std::get<0>(*tuple);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a parameter casted to the given type. Type checking does not happen
|
||||
* here!
|
||||
*
|
||||
* @param d Parameter information.
|
||||
* @param input Unused parameter.
|
||||
* @param output Place to store pointer to value.
|
||||
*/
|
||||
template<typename T>
|
||||
void GetParam(const util::ParamData& d, const void* /* input */, void* output)
|
||||
{
|
||||
// Cast to the correct type.
|
||||
*((T**) output) = &GetParam<typename std::remove_pointer<T>::type>(
|
||||
const_cast<util::ParamData&>(d));
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
* @file get_printable_param.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Print the parameter to stdout, using template metaprogramming to enforce
|
||||
* different behavior for different parameter types.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_HPP
|
||||
#define MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
#include <mlpack/core/util/is_std_vector.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Print an option.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Print a vector option, with spaces between it.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0);
|
||||
|
||||
/**
|
||||
* Print a matrix/tuple option (this just prints the filename).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value ||
|
||||
std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0);
|
||||
|
||||
/**
|
||||
* Print a model option (this just prints the filename).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Print an option into a std::string. This should print a short, one-line
|
||||
* representation of the object. The string will be stored in the output
|
||||
* pointer.
|
||||
*/
|
||||
template<typename T>
|
||||
void GetPrintableParam(const util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParam<typename std::remove_pointer<T>::type>(data);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation.
|
||||
#include "get_printable_param_impl.hpp"
|
||||
|
||||
#endif
|
||||
@@ -1,88 +0,0 @@
|
||||
/**
|
||||
* @file get_printable_param_impl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Implementation of parameter printing functions.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_IMPL_HPP
|
||||
#define MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_IMPL_HPP
|
||||
|
||||
#include "get_printable_param.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
//! Print an option.
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* /* junk */)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << boost::any_cast<T>(data.value);
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
//! Print a vector option.
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename std::enable_if<util::IsStdVector<T>::value>::type*
|
||||
/* junk */)
|
||||
{
|
||||
const T& t = boost::any_cast<T>(data.value);
|
||||
|
||||
std::ostringstream oss;
|
||||
for (size_t i = 0; i < t.size(); ++i)
|
||||
oss << t[i] << " ";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
//! Print a matrix/tuple option (this just prints the filename).
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value ||
|
||||
std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* /* junk */)
|
||||
{
|
||||
// Extract the string from the tuple that's being held.
|
||||
typedef std::tuple<T, typename ParameterType<T>::type> TupleType;
|
||||
const TupleType* tuple = boost::any_cast<TupleType>(&data.value);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << std::get<1>(*tuple);
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
//! Print a model option (this just prints the filename).
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
|
||||
{
|
||||
// Extract the string from the tuple that's being held.
|
||||
typedef std::tuple<T*, typename ParameterType<T>::type> TupleType;
|
||||
const TupleType* tuple = boost::any_cast<TupleType>(&data.value);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << std::get<1>(*tuple);
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,83 +0,0 @@
|
||||
/**
|
||||
* @file get_printable_param_name.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Return the parameter name that the user would specify on the command line,
|
||||
* with different behavior for different parameter types.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_NAME_HPP
|
||||
#define MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_NAME_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Get the parameter name for a type that has no special handling.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a matrix type (where the user has to pass the file
|
||||
* that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a serializable model type (where the user has to
|
||||
* pass the file that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a mapped matrix type (where the user has to pass
|
||||
* the file that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter's name as seen by the user.
|
||||
*/
|
||||
template<typename T>
|
||||
void GetPrintableParamName(
|
||||
const util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParamName<typename std::remove_pointer<T>::type>(d);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation.
|
||||
#include "get_printable_param_name_impl.hpp"
|
||||
|
||||
#endif
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* @file get_printable_param_name_impl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Return the parameter name that the user would specify on the command line,
|
||||
* with different behavior for different parameter types.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_NAME_IMPL_HPP
|
||||
#define MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_NAME_IMPL_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Get the parameter name for a type that has no special handling.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type*,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
|
||||
{
|
||||
return "--" + data.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter name for a matrix type (where the user has to pass the file
|
||||
* that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type*)
|
||||
{
|
||||
return "--" + data.name + "_file";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter name for a serializable model type (where the user has to
|
||||
* pass the file that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type*)
|
||||
{
|
||||
return "--" + data.name + "_file";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter name for a mapped matrix type (where the user has to pass
|
||||
* the file that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamName(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
|
||||
{
|
||||
return "--" + data.name + "_file";
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,88 +0,0 @@
|
||||
/**
|
||||
* @file get_printable_param_value.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Given a parameter value, print what the user might actually specify on the
|
||||
* command line. Basically this adds ".csv" to types where data must be loaded.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_VALUE_HPP
|
||||
#define MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_VALUE_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Get the parameter name for a type that has no special handling.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
const util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a matrix type (where the user has to pass the file
|
||||
* that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
const util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a serializable model type (where the user has to
|
||||
* pass the file that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
const util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter name for a mapped matrix type (where the user has to pass
|
||||
* the file that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
const util::ParamData& data,
|
||||
const std::string& value,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Get the parameter's name as seen by the user.
|
||||
*/
|
||||
template<typename T>
|
||||
void GetPrintableParamValue(
|
||||
const util::ParamData& d,
|
||||
const void* input,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParamValue<typename std::remove_pointer<T>::type>(d,
|
||||
*((std::string*) input));
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation.
|
||||
#include "get_printable_param_value_impl.hpp"
|
||||
|
||||
#endif
|
||||
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
* @file get_printable_param_value_impl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Return the parameter value that the user would specify on the command line
|
||||
* depending on the type of the option. Basically this adds ".csv" to types
|
||||
* that need to be loaded.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_VALUE_IMPL_HPP
|
||||
#define MLPACK_BINDINGS_CLI_GET_PRINTABLE_PARAM_VALUE_IMPL_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Get the parameter name for a type that has no special handling.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
const util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type*,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter name for a matrix type (where the user has to pass the file
|
||||
* that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
const util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type*)
|
||||
{
|
||||
return input + ".csv";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter name for a serializable model type (where the user has to
|
||||
* pass the file that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
const util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type*,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type*)
|
||||
{
|
||||
return input + ".bin";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter name for a mapped matrix type (where the user has to pass
|
||||
* the file that holds the matrix).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParamValue(
|
||||
const util::ParamData& /* data */,
|
||||
const std::string& input,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type*)
|
||||
{
|
||||
return input + ".arff";
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,93 +0,0 @@
|
||||
/**
|
||||
* @file get_raw_param.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Use template metaprogramming to get the right type of parameter, but without
|
||||
* any processing.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_GET_RAW_PARAM_HPP
|
||||
#define MLPACK_BINDINGS_CLI_GET_RAW_PARAM_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include "parameter_type.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* This overload is called when nothing special needs to happen to the name of
|
||||
* the parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
T& GetRawParam(
|
||||
util::ParamData& d,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
// No mapping is needed, so just cast it directly.
|
||||
return *boost::any_cast<T>(&d.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a matrix parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
T& GetRawParam(
|
||||
util::ParamData& d,
|
||||
const typename boost::enable_if_c<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value>::type* = 0)
|
||||
{
|
||||
// Don't load the matrix.
|
||||
typedef std::tuple<T, std::string> TupleType;
|
||||
T& value = std::get<0>(*boost::any_cast<TupleType>(&d.value));
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of a model parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
T*& GetRawParam(
|
||||
util::ParamData& d,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// Don't load the model.
|
||||
typedef std::tuple<T*, std::string> TupleType;
|
||||
T*& value = std::get<0>(*boost::any_cast<TupleType>(&d.value));
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a parameter casted to the given type. Type checking does not happen
|
||||
* here!
|
||||
*
|
||||
* @param d Parameter information.
|
||||
* @param input Unused parameter.
|
||||
* @param output Place to store pointer to value.
|
||||
*/
|
||||
template<typename T>
|
||||
void GetRawParam(const util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
// Cast to the correct type.
|
||||
*((T**) output) = &GetRawParam<typename std::remove_pointer<T>::type>(
|
||||
const_cast<util::ParamData&>(d));
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
/**
|
||||
* @file map_parameter_name.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Map a parameter name to what it seen by boost::program_options using template
|
||||
* metaprogramming.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_MAP_PARAMETER_NAME_HPP
|
||||
#define MLPACK_BINDINGS_CLI_MAP_PARAMETER_NAME_HPP
|
||||
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* If needed, map the parameter name to the name that is used by
|
||||
* boost::program_options. This overload simply returns the same name, so it is
|
||||
* used for primitive types.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string MapParameterName(
|
||||
const std::string& identifier,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
return identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map the parameter name to the name that is used by boost::program_options.
|
||||
* This overload addresses matrices and models, where the parameter name has
|
||||
* "_file" appended to it (since a filename will be provided).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string MapParameterName(
|
||||
const std::string& identifier,
|
||||
const typename boost::enable_if_c<
|
||||
arma::is_arma_type<T>::value ||
|
||||
std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
|
||||
arma::mat>>::value ||
|
||||
data::HasSerialize<T>::value>::type* /* junk */ = 0)
|
||||
{
|
||||
return identifier + "_file";
|
||||
}
|
||||
|
||||
/**
|
||||
* Map the parameter name to the name seen by boost::program_options.
|
||||
*
|
||||
* @param d Parameter data.
|
||||
* @param input Unused parameter.
|
||||
* @param output Pointer to std::string that will hold the mapped name.
|
||||
*/
|
||||
template<typename T>
|
||||
void MapParameterName(const util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
// Store the mapped name in the output pointer, which is actually a string
|
||||
// pointer.
|
||||
*((std::string*) output) =
|
||||
MapParameterName<typename std::remove_pointer<T>::type>(d.name);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,88 +0,0 @@
|
||||
/**
|
||||
* @file output_param.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Output a parameter of different types using template metaprogramming.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_OUTPUT_PARAM_HPP
|
||||
#define MLPACK_BINDINGS_CLI_OUTPUT_PARAM_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
#include <mlpack/core/util/is_std_vector.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Output an option (print to stdout).
|
||||
*/
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Output a vector option (print to stdout).
|
||||
*/
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Output a matrix option (this saves it to the given file).
|
||||
*/
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Output a serializable class option (this saves it to the given file).
|
||||
*/
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Output a mapped dataset.
|
||||
*/
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Output an option. This is the function that will be called by the CLI
|
||||
* module.
|
||||
*/
|
||||
template<typename T>
|
||||
void OutputParam(const util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
OutputParamImpl<typename std::remove_pointer<T>::type>(data);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation.
|
||||
#include "output_param_impl.hpp"
|
||||
|
||||
#endif
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* @file output_param_impl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Implementations of functions to output parameters of different types.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_CORE_UTIL_OUTPUT_PARAM_IMPL_HPP
|
||||
#define MLPACK_CORE_UTIL_OUTPUT_PARAM_IMPL_HPP
|
||||
|
||||
#include "output_param.hpp"
|
||||
#include <mlpack/core/data/save.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
//! Output an option.
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* /* junk */)
|
||||
{
|
||||
std::cout << data.name << ": " << *boost::any_cast<T>(&data.value)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
//! Output a vector option.
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
|
||||
{
|
||||
std::cout << data.name << ": ";
|
||||
const T& t = *boost::any_cast<T>(&data.value);
|
||||
for (size_t i = 0; i < t.size(); ++i)
|
||||
std::cout << t[i] << " ";
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
//! Output a matrix option (this saves it to file).
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* /* junk */)
|
||||
{
|
||||
typedef std::tuple<T, std::string> TupleType;
|
||||
const T& output = std::get<0>(*boost::any_cast<TupleType>(&data.value));
|
||||
const std::string& filename =
|
||||
std::get<1>(*boost::any_cast<TupleType>(&data.value));
|
||||
|
||||
if (output.n_elem > 0 && filename != "")
|
||||
{
|
||||
if (arma::is_Row<T>::value || arma::is_Col<T>::value)
|
||||
data::Save(filename, output, false);
|
||||
else
|
||||
data::Save(filename, output, false, !data.noTranspose);
|
||||
}
|
||||
}
|
||||
|
||||
//! Output a model option (this saves it to file).
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* /* junk */,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
|
||||
{
|
||||
// The const cast is necessary here because Serialize() can't ever be marked
|
||||
// const. In this case we can assume it though, since we will be saving and
|
||||
// not loading.
|
||||
typedef std::tuple<T*, std::string> TupleType;
|
||||
T*& output = const_cast<T*&>(std::get<0>(*boost::any_cast<TupleType>(
|
||||
&data.value)));
|
||||
const std::string& filename =
|
||||
std::get<1>(*boost::any_cast<TupleType>(&data.value));
|
||||
|
||||
if (filename != "")
|
||||
data::Save(filename, "model", *output);
|
||||
}
|
||||
|
||||
//! Output a mapped dataset.
|
||||
template<typename T>
|
||||
void OutputParamImpl(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* /* junk */)
|
||||
{
|
||||
// Output the matrix with the mappings.
|
||||
typedef std::tuple<T, std::string> TupleType;
|
||||
const T& tuple = std::get<0>(*boost::any_cast<TupleType>(&data.value));
|
||||
const std::string& filename =
|
||||
std::get<1>(*boost::any_cast<TupleType>(&data.value));
|
||||
const arma::mat& matrix = std::get<1>(tuple);
|
||||
|
||||
// The mapping isn't taken into account. We should write a data::Save()
|
||||
// overload for this.
|
||||
if (filename != "")
|
||||
data::Save(filename, matrix, false, !data.noTranspose);
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,96 +0,0 @@
|
||||
/**
|
||||
* @file parameter_type.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Template metaprogramming structures to find the type (as seen by
|
||||
* boost::program_options) of a particular option type.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_PARAMETER_TYPE_HPP
|
||||
#define MLPACK_BINDINGS_CLI_PARAMETER_TYPE_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
// Default: HasSerialize = false.
|
||||
template<bool HasSerialize, typename T>
|
||||
struct ParameterTypeDeducer
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// If we have a serialize() function, then the type is a string.
|
||||
template<typename T>
|
||||
struct ParameterTypeDeducer<true, T>
|
||||
{
|
||||
typedef std::string type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility struct to return the type that boost::program_options should accept
|
||||
* for a given input type. In general, there is no change from the input type,
|
||||
* but in some cases this may be another type.
|
||||
*/
|
||||
template<typename T>
|
||||
struct ParameterType
|
||||
{
|
||||
typedef typename ParameterTypeDeducer<data::HasSerialize<T>::value, T>::type
|
||||
type;
|
||||
};
|
||||
|
||||
/**
|
||||
* For vector types, boost::program_options will accept a std::string, not an
|
||||
* arma::Col<eT> (since it is not clear how to specify a vector on the
|
||||
* command-line).
|
||||
*/
|
||||
template<typename eT>
|
||||
struct ParameterType<arma::Col<eT>>
|
||||
{
|
||||
typedef std::string type;
|
||||
};
|
||||
|
||||
/**
|
||||
* For row vector types, boost::program_options will accept a std::string, not
|
||||
* an
|
||||
* arma::Row<eT> (since it is not clear how to specify a vector on the
|
||||
* command-line).
|
||||
*/
|
||||
template<typename eT>
|
||||
struct ParameterType<arma::Row<eT>>
|
||||
{
|
||||
typedef std::string type;
|
||||
};
|
||||
|
||||
/**
|
||||
* For matrix types, boost::program_options will accept a std::string, not an
|
||||
* arma::mat (since it is not clear how to specify a matrix on the
|
||||
* command-line).
|
||||
*/
|
||||
template<typename eT>
|
||||
struct ParameterType<arma::Mat<eT>>
|
||||
{
|
||||
typedef std::string type;
|
||||
};
|
||||
|
||||
/**
|
||||
* For matrix+dataset info types, we should accept a std::string.
|
||||
*/
|
||||
template<typename eT, typename PolicyType>
|
||||
struct ParameterType<std::tuple<mlpack::data::DatasetMapper<PolicyType,
|
||||
std::string>, arma::Mat<eT>>>
|
||||
{
|
||||
typedef std::string type;
|
||||
};
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,201 +0,0 @@
|
||||
/**
|
||||
* @file parse_command_line.hpp
|
||||
* @author Ryan Curtin
|
||||
* @author Matthew Amidon
|
||||
*
|
||||
* Parse the command line options.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_PARSE_COMMAND_LINE_HPP
|
||||
#define MLPACK_BINDINGS_CLI_PARSE_COMMAND_LINE_HPP
|
||||
|
||||
#include <mlpack/core.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include "print_help.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
// Add default parameters that are included in every program.
|
||||
PARAM_FLAG("help", "Default help info.", "h");
|
||||
PARAM_STRING_IN("info", "Get help on a specific module or option.", "", "");
|
||||
PARAM_FLAG("verbose", "Display informational messages and the full list of "
|
||||
"parameters and timers at the end of execution.", "v");
|
||||
PARAM_FLAG("version", "Display the version of mlpack.", "V");
|
||||
|
||||
/**
|
||||
* Parse the command line, setting all of the options inside of the CLI object
|
||||
* to their appropriate given values.
|
||||
*/
|
||||
void ParseCommandLine(int argc, char** argv)
|
||||
{
|
||||
// First, we need to build the boost::program_options variables for parsing.
|
||||
using namespace boost::program_options;
|
||||
options_description desc;
|
||||
variables_map vmap;
|
||||
|
||||
// Go through list of options in order to add them.
|
||||
std::map<std::string, util::ParamData>& parameters = CLI::Parameters();
|
||||
typedef std::map<std::string, util::ParamData>::const_iterator IteratorType;
|
||||
std::map<std::string, std::string> boostNameMap;
|
||||
for (IteratorType it = parameters.begin(); it != parameters.end(); ++it)
|
||||
{
|
||||
// Add the parameter to desc.
|
||||
const util::ParamData& d = it->second;
|
||||
CLI::GetSingleton().functionMap[d.tname]["AddToPO"](d, NULL,
|
||||
(void*) &desc);
|
||||
|
||||
// Generate the name the user passes on the command line.
|
||||
std::string boostName;
|
||||
CLI::GetSingleton().functionMap[d.tname]["MapParameterName"](d, NULL,
|
||||
(void*) &boostName);
|
||||
boostNameMap[boostName] = d.name;
|
||||
}
|
||||
|
||||
// Mark that we did parsing.
|
||||
CLI::GetSingleton().didParse = true;
|
||||
|
||||
// Parse the command line, then place the values in the right place.
|
||||
try
|
||||
{
|
||||
basic_parsed_options<char> bpo(parse_command_line(argc, argv, desc));
|
||||
|
||||
// Iterate over all the options, looking for duplicate parameters. If we
|
||||
// find any, remove the duplicates. Note that vector options can have
|
||||
// duplicates, so we check for those with max_tokens().
|
||||
for (size_t i = 0; i < bpo.options.size(); ++i)
|
||||
{
|
||||
for (size_t j = i + 1; j < bpo.options.size(); ++j)
|
||||
{
|
||||
if ((bpo.options[i].string_key == bpo.options[j].string_key) &&
|
||||
(desc.find(bpo.options[i].string_key,
|
||||
false).semantic()->max_tokens() <= 1))
|
||||
{
|
||||
// If a duplicate is found, check to see if either one has a value.
|
||||
if (bpo.options[i].value.size() == 0 &&
|
||||
bpo.options[j].value.size() == 0)
|
||||
{
|
||||
// If neither has a value, we'll consider it a duplicate flag and
|
||||
// remove the duplicate. It's important to not break out of this
|
||||
// loop because there might be another duplicate later on in the
|
||||
// vector.
|
||||
bpo.options.erase(bpo.options.begin() + j);
|
||||
--j; // Fix the index.
|
||||
}
|
||||
else
|
||||
{
|
||||
// If one or both has a value, produce an error and politely
|
||||
// terminate. We pull the name from the original_tokens, rather
|
||||
// than from the string_key, because the string_key is the parameter
|
||||
// after aliases have been expanded.
|
||||
Log::Fatal << "\"" << bpo.options[j].original_tokens[0] << "\" is "
|
||||
<< "defined multiple times." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
store(bpo, vmap);
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
Log::Fatal << "Caught exception from parsing command line: " << ex.what()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// Now iterate through the filled vmap, and overwrite default values with
|
||||
// anything that's found on the command line.
|
||||
for (variables_map::iterator i = vmap.begin(); i != vmap.end(); ++i)
|
||||
{
|
||||
// There is not a possibility of an unknown option, since
|
||||
// boost::program_options would have already thrown an exception. Because
|
||||
// some names may be mapped, we have to look through each ParamData object
|
||||
// and get its boost name.
|
||||
const std::string identifier = boostNameMap[i->first];
|
||||
util::ParamData& param = parameters[identifier];
|
||||
param.wasPassed = true;
|
||||
CLI::GetSingleton().functionMap[param.tname]["SetParam"](param,
|
||||
(void*) &vmap[i->first].value(), NULL);
|
||||
}
|
||||
|
||||
// Flush the buffer, make sure changes are propagated to vmap.
|
||||
notify(vmap);
|
||||
|
||||
// If the user specified any of the default options (--help, --version, or
|
||||
// --info), handle those.
|
||||
|
||||
// --version is prioritized over --help.
|
||||
if (CLI::HasParam("version"))
|
||||
{
|
||||
std::cout << CLI::GetSingleton().ProgramName() << ": part of "
|
||||
<< util::GetVersion() << "." << std::endl;
|
||||
exit(0); // Don't do anything else.
|
||||
}
|
||||
|
||||
// Default help message.
|
||||
if (CLI::HasParam("help"))
|
||||
{
|
||||
Log::Info.ignoreInput = false;
|
||||
PrintHelp();
|
||||
exit(0); // The user doesn't want to run the program, he wants help.
|
||||
}
|
||||
|
||||
// Info on a specific parameter.
|
||||
if (CLI::HasParam("info"))
|
||||
{
|
||||
Log::Info.ignoreInput = false;
|
||||
std::string str = CLI::GetParam<std::string>("info");
|
||||
|
||||
// The info node should always be there, but the user may not have specified
|
||||
// anything.
|
||||
if (str != "")
|
||||
{
|
||||
PrintHelp(str);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Otherwise just print the generalized help.
|
||||
PrintHelp();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Print whether or not we have debugging symbols. This won't show anything
|
||||
// if we have not compiled in debugging mode.
|
||||
Log::Debug << "Compiled with debugging symbols." << std::endl;
|
||||
|
||||
if (CLI::HasParam("verbose"))
|
||||
{
|
||||
// Give [INFO ] output.
|
||||
Log::Info.ignoreInput = false;
|
||||
}
|
||||
|
||||
// Now, issue an error if we forgot any required options.
|
||||
for (std::map<std::string, util::ParamData>::const_iterator iter =
|
||||
parameters.begin(); iter != parameters.end(); ++iter)
|
||||
{
|
||||
const util::ParamData d = iter->second;
|
||||
if (d.required)
|
||||
{
|
||||
const std::string boostName;
|
||||
CLI::GetSingleton().functionMap[d.tname]["MapParameterName"](d, NULL,
|
||||
(void*) &boostName);
|
||||
|
||||
if (!vmap.count(boostName))
|
||||
{
|
||||
Log::Fatal << "Required option --" << boostName << " is undefined."
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,82 +0,0 @@
|
||||
/**
|
||||
* @file print_doc_functions.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* This will generate a string representing what a user should type to invoke a
|
||||
* given option. For the command-line bindings, this will generate strings like
|
||||
* '--param_name=x' or '--param_name'.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_PRINT_DOC_FUNCTIONS_HPP
|
||||
#define MLPACK_BINDINGS_CLI_PRINT_DOC_FUNCTIONS_HPP
|
||||
|
||||
#include <mlpack/core/util/hyphenate_string.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Given a parameter type, print the corresponding value.
|
||||
*/
|
||||
template<typename T>
|
||||
inline std::string PrintValue(const T& value, bool quotes);
|
||||
|
||||
/**
|
||||
* Print a dataset type parameter (add .csv and return).
|
||||
*/
|
||||
inline std::string PrintDataset(const std::string& dataset);
|
||||
|
||||
/**
|
||||
* Print a model type parameter (add .bin and return).
|
||||
*/
|
||||
inline std::string PrintModel(const std::string& model);
|
||||
|
||||
/**
|
||||
* Base case for recursion.
|
||||
*/
|
||||
inline std::string ProcessOptions();
|
||||
|
||||
/**
|
||||
* Print an option for a command-line argument.
|
||||
*/
|
||||
template<typename T, typename... Args>
|
||||
std::string ProcessOptions(const std::string& paramName,
|
||||
const T& value,
|
||||
Args... args);
|
||||
|
||||
/**
|
||||
* Given a program name and arguments for it, print what its invocation would
|
||||
* be.
|
||||
*/
|
||||
template<typename... Args>
|
||||
std::string ProgramCall(const std::string& programName, Args... args);
|
||||
|
||||
/**
|
||||
* Print what a user would type to invoke the given option name. Note that the
|
||||
* name *must* exist in the CLI module. (Note that because of the way
|
||||
* ProgramInfo is structured, this doesn't mean that all of the PARAM_*()
|
||||
* declarataions need to come before the PROGRAM_INFO() declaration.)
|
||||
*/
|
||||
inline std::string ParamString(const std::string& paramName);
|
||||
|
||||
/**
|
||||
* Return whether or not a runtime check on parameters should be ignored. We
|
||||
* don't ignore any runtime checks for CLI bindings, so this always returns
|
||||
* false.
|
||||
*/
|
||||
template<typename T>
|
||||
inline bool IgnoreCheck(const T& /* t */) { return false; }
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation.
|
||||
#include "print_doc_functions_impl.hpp"
|
||||
|
||||
#endif
|
||||
@@ -1,148 +0,0 @@
|
||||
/**
|
||||
* @file print_doc_functions_impl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* This will generate a string representing what a user should type to invoke a
|
||||
* given option. For the command-line bindings, this will generate strings like
|
||||
* '--param_name=x' or '--param_name'.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_PRINT_DOC_FUNCTIONS_IMPL_HPP
|
||||
#define MLPACK_BINDINGS_CLI_PRINT_DOC_FUNCTIONS_IMPL_HPP
|
||||
|
||||
#include <mlpack/core/util/hyphenate_string.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Given a parameter type, print the corresponding value.
|
||||
*/
|
||||
template<typename T>
|
||||
inline std::string PrintValue(const T& value, bool quotes)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (quotes)
|
||||
oss << "'";
|
||||
oss << value;
|
||||
if (quotes)
|
||||
oss << "'";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a dataset type parameter (add .csv and return).
|
||||
*/
|
||||
inline std::string PrintDataset(const std::string& dataset)
|
||||
{
|
||||
return "'" + dataset + ".csv'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a model type parameter (add .bin and return).
|
||||
*/
|
||||
inline std::string PrintModel(const std::string& model)
|
||||
{
|
||||
return "'" + model + ".bin'";
|
||||
}
|
||||
|
||||
// Base case for recursion.
|
||||
inline std::string ProcessOptions() { return ""; }
|
||||
|
||||
/**
|
||||
* Print an option for a command-line argument.
|
||||
*/
|
||||
template<typename T, typename... Args>
|
||||
std::string ProcessOptions(const std::string& paramName,
|
||||
const T& value,
|
||||
Args... args)
|
||||
{
|
||||
// See if it is part of the program.
|
||||
std::string result = "";
|
||||
if (CLI::Parameters().count(paramName) > 0)
|
||||
{
|
||||
const util::ParamData& d = CLI::Parameters()[paramName];
|
||||
|
||||
std::string name;
|
||||
CLI::GetSingleton().functionMap[d.tname]["GetPrintableParamName"](d, NULL,
|
||||
(void*) &name);
|
||||
|
||||
std::ostringstream ossValue;
|
||||
ossValue << value;
|
||||
std::string rawValue = ossValue.str();
|
||||
std::string fullValue;
|
||||
CLI::GetSingleton().functionMap[d.tname]["GetPrintableParamValue"](d,
|
||||
(void*) &rawValue, (void*) &fullValue);
|
||||
|
||||
std::ostringstream oss;
|
||||
if (d.tname != TYPENAME(bool))
|
||||
oss << name << " " << fullValue;
|
||||
else
|
||||
oss << name;
|
||||
result = oss.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Unknown parameter '" + paramName + "' " +
|
||||
"encountered while assembling documentation! Check PROGRAM_INFO() " +
|
||||
"declaration.");
|
||||
}
|
||||
|
||||
std::string rest = ProcessOptions(args...);
|
||||
if (rest != "")
|
||||
result += " " + rest;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a program name and arguments for it, print what its invocation would
|
||||
* be.
|
||||
*/
|
||||
template<typename... Args>
|
||||
std::string ProgramCall(const std::string& programName, Args... args)
|
||||
{
|
||||
return util::HyphenateString("$ " + programName + " " +
|
||||
ProcessOptions(args...), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print what a user would type to invoke the given option name. Note that the
|
||||
* name *must* exist in the CLI module. (Note that because of the way
|
||||
* ProgramInfo is structured, this doesn't mean that all of the PARAM_*()
|
||||
* declarataions need to come before the PROGRAM_INFO() declaration.)
|
||||
*/
|
||||
inline std::string ParamString(const std::string& paramName)
|
||||
{
|
||||
// Return the correct parameter name.
|
||||
if (CLI::Parameters().count(paramName) > 0)
|
||||
{
|
||||
util::ParamData& d = CLI::Parameters()[paramName];
|
||||
|
||||
std::string output;
|
||||
CLI::GetSingleton().functionMap[d.tname]["GetPrintableParamName"](d, NULL,
|
||||
(void*) &output);
|
||||
// Is there an alias?
|
||||
std::string alias = "";
|
||||
if (d.alias != '\0')
|
||||
alias = " (-" + std::string(1, d.alias) + ")";
|
||||
|
||||
return "'" + output + alias + "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Parameter '" + paramName + "' not known! Check "
|
||||
"PROGRAM_INFO() definition.");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* @file print_help.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Print help for a command-line program.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_PRINT_HELP_HPP
|
||||
#define MLPACK_BINDINGS_CLI_PRINT_HELP_HPP
|
||||
|
||||
#include <mlpack/core.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Print the help for the given parameter. If no parameter is specified, then
|
||||
* help will be printed for all parameters.
|
||||
*
|
||||
* @param param Parameter name to print help for.
|
||||
*/
|
||||
void PrintHelp(const std::string& param = "");
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,107 +0,0 @@
|
||||
/**
|
||||
* @file get_param.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Use template metaprogramming to get the right type of parameter.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_SET_PARAM_HPP
|
||||
#define MLPACK_BINDINGS_CLI_SET_PARAM_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include "parameter_type.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* This overload is called when nothing special needs to happen to the name of
|
||||
* the parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
void SetParam(
|
||||
util::ParamData& d,
|
||||
const boost::any& value,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T, bool>>::type* = 0)
|
||||
{
|
||||
// No mapping is needed.
|
||||
d.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This overload is called to set a boolean.
|
||||
*/
|
||||
template<typename T>
|
||||
void SetParam(
|
||||
util::ParamData& d,
|
||||
const boost::any& /* value */,
|
||||
const typename boost::enable_if<std::is_same<T, bool>>::type* = 0)
|
||||
{
|
||||
// Force set to the value of whether or not this was passed.
|
||||
d.value = d.wasPassed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a matrix parameter, a matrix/dataset info parameter, or a serializable
|
||||
* object. These set the filename referring to the parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
void SetParam(
|
||||
util::ParamData& d,
|
||||
const boost::any& value,
|
||||
const typename std::enable_if<arma::is_arma_type<T>::value ||
|
||||
std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
|
||||
{
|
||||
// We're setting the string filename.
|
||||
typedef std::tuple<T, typename ParameterType<T>::type> TupleType;
|
||||
TupleType& tuple = *boost::any_cast<TupleType>(&d.value);
|
||||
std::get<1>(tuple) = boost::any_cast<std::string>(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a serializable object. This sets the filename referring to the
|
||||
* parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
void SetParam(
|
||||
util::ParamData& d,
|
||||
const boost::any& value,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// We're setting the string filename.
|
||||
typedef std::tuple<T*, typename ParameterType<T>::type> TupleType;
|
||||
TupleType& tuple = *boost::any_cast<TupleType>(&d.value);
|
||||
std::get<1>(tuple) = boost::any_cast<std::string>(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a parameter casted to the given type. Type checking does not happen
|
||||
* here!
|
||||
*
|
||||
* @param d Parameter information.
|
||||
* @param input Unused parameter.
|
||||
* @param output Place to store pointer to value.
|
||||
*/
|
||||
template<typename T>
|
||||
void SetParam(const util::ParamData& d, const void* input, void* /* output */)
|
||||
{
|
||||
SetParam<typename std::remove_pointer<T>::type>(
|
||||
const_cast<util::ParamData&>(d), *((boost::any*) input));
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,103 +0,0 @@
|
||||
/**
|
||||
* @file string_type_param.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Given a util::ParamData object, return a string containing the type of the input
|
||||
* parameter as given on the command-line.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_STRING_TYPE_PARAM_HPP
|
||||
#define MLPACK_BINDINGS_CLI_STRING_TYPE_PARAM_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
#include <mlpack/core/util/is_std_vector.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Return a string containing the type of the parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Return a string containing the type of the parameter, for vector options.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Return a string containing the type of the parameter,
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0);
|
||||
|
||||
/**
|
||||
* Return a string containing the type of a parameter. This overload is used if
|
||||
* we don't have a primitive type.
|
||||
*/
|
||||
template<typename T>
|
||||
void StringTypeParam(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = StringTypeParamImpl<T>();
|
||||
}
|
||||
|
||||
//! Return "int".
|
||||
template<>
|
||||
inline void StringTypeParam<int>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output);
|
||||
|
||||
//! Return "bool".
|
||||
template<>
|
||||
inline void StringTypeParam<bool>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output);
|
||||
|
||||
//! Return "string".
|
||||
template<>
|
||||
inline void StringTypeParam<std::string>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output);
|
||||
|
||||
//! Return "float".
|
||||
template<>
|
||||
inline void StringTypeParam<float>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output);
|
||||
|
||||
//! Return "double".
|
||||
template<>
|
||||
inline void StringTypeParam<double>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output);
|
||||
|
||||
//! Return "string";
|
||||
template<>
|
||||
inline void StringTypeParam<std::tuple<mlpack::data::DatasetInfo, arma::mat>>(
|
||||
const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output);
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation.
|
||||
#include "string_type_param_impl.hpp"
|
||||
|
||||
#endif
|
||||
@@ -1,118 +0,0 @@
|
||||
/**
|
||||
* @file string_type_param_impl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Implementations of StringTypeParam().
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_CLI_STRING_TYPE_PARAM_IMPL_HPP
|
||||
#define MLPACK_BINDINGS_CLI_STRING_TYPE_PARAM_IMPL_HPP
|
||||
|
||||
#include "string_type_param.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace cli {
|
||||
|
||||
/**
|
||||
* Return a string containing the type of the parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* /* junk */,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* /* junk */)
|
||||
{
|
||||
// Don't know what type this is.
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string containing the type of the parameter, for vector options.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* /* junk */)
|
||||
{
|
||||
return "vector";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string containing the type of the parameter,
|
||||
*/
|
||||
template<typename T>
|
||||
std::string StringTypeParamImpl(
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* /* junk */)
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
|
||||
//! Return "int".
|
||||
template<>
|
||||
inline void StringTypeParam<int>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = "int";
|
||||
}
|
||||
|
||||
//! Return "bool".
|
||||
template<>
|
||||
inline void StringTypeParam<bool>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = "bool";
|
||||
}
|
||||
|
||||
//! Return "string".
|
||||
template<>
|
||||
inline void StringTypeParam<std::string>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = "string";
|
||||
}
|
||||
|
||||
//! Return "float".
|
||||
template<>
|
||||
inline void StringTypeParam<float>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = "float";
|
||||
}
|
||||
|
||||
//! Return "double".
|
||||
template<>
|
||||
inline void StringTypeParam<double>(const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = "double";
|
||||
}
|
||||
|
||||
//! Return "string";
|
||||
template<>
|
||||
inline void StringTypeParam<std::tuple<mlpack::data::DatasetInfo, arma::mat>>(
|
||||
const util::ParamData& /* data */,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
std::string* outstr = (std::string*) output;
|
||||
*outstr = "string";
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* @file get_arma_type.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Return "mat", "col", or "row" depending on the type of the given Armadillo
|
||||
* object. This is so that the correct overload of arma_numpy.numpy_to_<type>()
|
||||
* can be called.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_GET_ARMA_TYPE_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_GET_ARMA_TYPE_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* This is used for arma::Mat<> types; it will return "mat" for matrices, "row"
|
||||
* for row vectors, and "col" for column vectors.
|
||||
*/
|
||||
template<typename T>
|
||||
inline std::string GetArmaType()
|
||||
{
|
||||
if (T::is_col)
|
||||
return "col";
|
||||
else if (T::is_row)
|
||||
return "row";
|
||||
else
|
||||
return "mat";
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,128 +0,0 @@
|
||||
/**
|
||||
* @file get_cython_type.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Template metaprogramming to return the string representation of the Cython
|
||||
* type for a given Cython binding parameter.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_GET_CYTHON_TYPE_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_GET_CYTHON_TYPE_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/is_std_vector.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetCythonType(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetCythonType<int>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<int>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<int>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<int>>::type*)
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetCythonType<float>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<float>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<float>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<float>>::type*)
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetCythonType<double>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<double>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<double>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<double>>::type*)
|
||||
{
|
||||
return "double";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetCythonType<std::string>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*)
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetCythonType<size_t>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<size_t>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<size_t>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<size_t>>::type*)
|
||||
{
|
||||
return "size_t";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetCythonType<bool>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<bool>>::type*)
|
||||
{
|
||||
return "bool";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetCythonType(
|
||||
const util::ParamData& d,
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
|
||||
{
|
||||
return "vector[" + GetCythonType<typename T::value_type>(d) + "]";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetCythonType(
|
||||
const util::ParamData& d,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
std::string type = "Mat";
|
||||
if (T::is_row)
|
||||
type = "Row";
|
||||
else if (T::is_col)
|
||||
type = "Col";
|
||||
|
||||
return "arma." + type + "[" + GetCythonType<typename T::elem_type>(d) + "]";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetCythonType(
|
||||
const util::ParamData& d,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
return d.cppType + "*";
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,43 +0,0 @@
|
||||
/**
|
||||
* @file get_numpy_type.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Given a C++ type, return the Python numpy dtype associated with that type.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_GET_NUMPY_TYPE_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_GET_NUMPY_TYPE_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetNumpyType()
|
||||
{
|
||||
return "unknown"; // Not sure...
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetNumpyType<double>()
|
||||
{
|
||||
return "np.double";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetNumpyType<size_t>()
|
||||
{
|
||||
return "np.intp";
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,70 +0,0 @@
|
||||
/**
|
||||
* @file get_numpy_type_char.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Given a matrix type, return the letter we should append to get the right
|
||||
* arma_numpy method call.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_GET_NUMPY_TYPE_CHAR_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_GET_NUMPY_TYPE_CHAR_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetNumpyTypeChar()
|
||||
{
|
||||
return "?";
|
||||
}
|
||||
|
||||
// size_t = s.
|
||||
template<>
|
||||
inline std::string GetNumpyTypeChar<arma::Mat<size_t>>()
|
||||
{
|
||||
return "s";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetNumpyTypeChar<arma::Col<size_t>>()
|
||||
{
|
||||
return "s";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetNumpyTypeChar<arma::Row<size_t>>()
|
||||
{
|
||||
return "s";
|
||||
}
|
||||
|
||||
// double = d.
|
||||
template<>
|
||||
inline std::string GetNumpyTypeChar<arma::mat>()
|
||||
{
|
||||
return "d";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetNumpyTypeChar<arma::vec>()
|
||||
{
|
||||
return "d";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetNumpyTypeChar<arma::rowvec>()
|
||||
{
|
||||
return "d";
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* @file get_param.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Get a parameter for a Python binding.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_GET_PARAM_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_GET_PARAM_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* All Python binding types are exactly what is held in the ParamData, so no
|
||||
* special handling is necessary.
|
||||
*/
|
||||
template<typename T>
|
||||
void GetParam(const util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((T**) output) = const_cast<T*>(boost::any_cast<T>(&d.value));
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,126 +0,0 @@
|
||||
/**
|
||||
* @file get_printable_param.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Get a printable version of parameters.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_GET_PRINTABLE_PARAM_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_GET_PRINTABLE_PARAM_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/is_std_vector.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Print an option of a simple type.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << boost::any_cast<T>(data.value);
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a vector option, with spaces between it.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
|
||||
{
|
||||
const T& t = boost::any_cast<T>(data.value);
|
||||
|
||||
std::ostringstream oss;
|
||||
for (size_t i = 0; i < t.size(); ++i)
|
||||
oss << t[i] << " ";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a matrix option (this prints its size).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& matrix = boost::any_cast<T>(data.value);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << matrix.n_rows << "x" << matrix.n_cols << " matrix";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a serializable class option (this prints the class name).
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << data.cppType << " model at " << boost::any_cast<T*>(data.value);
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a combination DatasetInfo/matrix parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string GetPrintableParam(
|
||||
const util::ParamData& data,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
// Get the matrix.
|
||||
const T& tuple = boost::any_cast<T>(data.value);
|
||||
const arma::mat& matrix = std::get<1>(tuple);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << matrix.n_rows << "x" << matrix.n_cols << " matrix with dimension type "
|
||||
<< "information";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an option into a std::string. This should print a short, one-line
|
||||
* representation of the object. The string will be stored in the output
|
||||
* pointer.
|
||||
*
|
||||
* @param data Parameter data struct.
|
||||
* @param input Unused parameter.
|
||||
* @param output Output storage for the string.
|
||||
*/
|
||||
template<typename T>
|
||||
void GetPrintableParam(const util::ParamData& data,
|
||||
const void* /* input */,
|
||||
void* output)
|
||||
{
|
||||
*((std::string*) output) =
|
||||
GetPrintableParam<typename std::remove_pointer<T>::type>(data);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,128 +0,0 @@
|
||||
/**
|
||||
* @file get_python_type.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Template metaprogramming to return the string representation of the Python
|
||||
* type for a given Python binding parameter.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_GET_PYTHON_TYPE_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_GET_PYTHON_TYPE_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/is_std_vector.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPythonType(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetPythonType<int>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<int>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<int>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<int>>::type*)
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetPythonType<float>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<float>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<float>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<float>>::type*)
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetPythonType<double>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<double>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<double>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<double>>::type*)
|
||||
{
|
||||
return "double";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetPythonType<std::string>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<std::string>>::type*)
|
||||
{
|
||||
return "string";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetPythonType<size_t>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<size_t>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<size_t>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<size_t>>::type*)
|
||||
{
|
||||
return "size_t";
|
||||
}
|
||||
|
||||
template<>
|
||||
inline std::string GetPythonType<bool>(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<util::IsStdVector<bool>>::type*,
|
||||
const typename boost::disable_if<data::HasSerialize<bool>>::type*,
|
||||
const typename boost::disable_if<arma::is_arma_type<bool>>::type*)
|
||||
{
|
||||
return "bool";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPythonType(
|
||||
const util::ParamData& d,
|
||||
const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
|
||||
{
|
||||
return "list of " + GetPythonType<typename T::value_type>(d) + "s";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPythonType(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
std::string type = "matrix";
|
||||
if (T::is_row)
|
||||
type = "row vector";
|
||||
else if (T::is_col)
|
||||
type = "column vector";
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::string GetPythonType(
|
||||
const util::ParamData& d,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
return d.cppType + "Type";
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,94 +0,0 @@
|
||||
/**
|
||||
* @file import_decl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* For a serializable model, print the class import.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_IMPORT_DECL_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_IMPORT_DECL_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include "strip_type.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* For a serializable type, print a cppclass definition.
|
||||
*/
|
||||
template<typename T>
|
||||
void ImportDecl(
|
||||
const util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// First, we have to parse the type. If we have something like, e.g.,
|
||||
// 'LogisticRegression<>', we must convert this to 'LogisticRegression[T=*].'
|
||||
std::string strippedType, printedType, defaultsType;
|
||||
StripType(d.cppType, strippedType, printedType, defaultsType);
|
||||
|
||||
/**
|
||||
* This will give output of the form:
|
||||
*
|
||||
* cdef cppclass Type:
|
||||
* Type() nogil
|
||||
*/
|
||||
const std::string prefix = std::string(indent, ' ');
|
||||
std::cout << prefix << "cdef cppclass " << defaultsType << ":" << std::endl;
|
||||
std::cout << prefix << " " << strippedType << "() nogil" << std::endl;
|
||||
std::cout << prefix << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a non-serializable type, print nothing.
|
||||
*/
|
||||
template<typename T>
|
||||
void ImportDecl(
|
||||
const util::ParamData& /* d */,
|
||||
const size_t /* indent */,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// Print nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* For a matrix type, print nothing.
|
||||
*/
|
||||
template<typename T>
|
||||
void ImportDecl(
|
||||
const util::ParamData& /* d */,
|
||||
const size_t /* indent */,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
// Print nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the cppclass definition for a serializable model; print nothing for a
|
||||
* non-serializable type.
|
||||
*
|
||||
* @param d Parameter info struct.
|
||||
* @param input Pointer to size_t indicating indent.
|
||||
* @param output Unused parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
void ImportDecl(const util::ParamData& d,
|
||||
const void* indent,
|
||||
void* /* output */)
|
||||
{
|
||||
ImportDecl<typename std::remove_pointer<T>::type>(d, *((size_t*) indent));
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,63 +0,0 @@
|
||||
/**
|
||||
* @file arma_util.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Utility function for Cython to set the memory state of an Armadillo object.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_CYTHON_ARMA_UTIL_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_CYTHON_ARMA_UTIL_HPP
|
||||
|
||||
// Include Armadillo via mlpack.
|
||||
#include <mlpack/core.hpp>
|
||||
|
||||
/**
|
||||
* Set the memory state of the given Armadillo object.
|
||||
*/
|
||||
template<typename T>
|
||||
void SetMemState(T& t, int state)
|
||||
{
|
||||
const_cast<arma::uhword&>(t.mem_state) = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the memory state of the given Armadillo object.
|
||||
*/
|
||||
template<typename T>
|
||||
size_t GetMemState(T& t)
|
||||
{
|
||||
// Fake the memory state if we are using preallocated memory---since we will
|
||||
// end up copying that memory, NumPy can own it.
|
||||
if (t.mem && t.n_elem <= arma::arma_config::mat_prealloc)
|
||||
return 0;
|
||||
|
||||
return (size_t) t.mem_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the matrix's allocated memory pointer, unless the matrix is using its
|
||||
* internal preallocated memory, in which case we copy that and return a
|
||||
* pointer to the memory we just made.
|
||||
*/
|
||||
template<typename T>
|
||||
inline typename T::elem_type* GetMemory(T& m)
|
||||
{
|
||||
if (m.mem && m.n_elem <= arma::arma_config::mat_prealloc)
|
||||
{
|
||||
// We need to allocate new memory.
|
||||
typename T::elem_type* mem =
|
||||
arma::memory::acquire<typename T::elem_type>(m.n_elem);
|
||||
arma::arrayops::copy(mem, m.memptr(), m.n_elem);
|
||||
return mem;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m.memptr();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,169 +0,0 @@
|
||||
/**
|
||||
* @file cli_util.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Simple function to work around Cython's lack of support for lvalue
|
||||
* references.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_CYTHON_CLI_UTIL_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_CYTHON_CLI_UTIL_HPP
|
||||
|
||||
#include <mlpack/core/util/cli.hpp>
|
||||
#include <mlpack/core/data/dataset_mapper.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace util {
|
||||
|
||||
/**
|
||||
* Set the parameter to the given value.
|
||||
*
|
||||
* This function exists to work around Cython's lack of support for lvalue
|
||||
* references.
|
||||
*
|
||||
* @param identifier Name of parameter.
|
||||
* @param value Value to set parameter to.
|
||||
*/
|
||||
template<typename T>
|
||||
inline void SetParam(const std::string& identifier, T& value)
|
||||
{
|
||||
CLI::GetParam<T>(identifier) = std::move(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parameter to the given value, given that the type is a pointer.
|
||||
*
|
||||
* This function exists to work around both Cython's lack of support for lvalue
|
||||
* references and also its seeming lack of support for template pointer types.
|
||||
*
|
||||
* @param identifier Name of parameter.
|
||||
* @param value Value to set parameter to.
|
||||
* @param copy Whether or not the object should be copied.
|
||||
*/
|
||||
template<typename T>
|
||||
inline void SetParamPtr(const std::string& identifier,
|
||||
T* value,
|
||||
const bool copy)
|
||||
{
|
||||
CLI::GetParam<T*>(identifier) = copy ? new T(*value) : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parameter (which is a matrix/DatasetInfo tuple) to the given value.
|
||||
*/
|
||||
template<typename T>
|
||||
inline void SetParamWithInfo(const std::string& identifier,
|
||||
T& matrix,
|
||||
const bool* dims)
|
||||
{
|
||||
typedef typename std::tuple<data::DatasetInfo, T> TupleType;
|
||||
typedef typename T::elem_type eT;
|
||||
|
||||
// The true type of the parameter is std::tuple<T, DatasetInfo>.
|
||||
const size_t dimensions = matrix.n_rows;
|
||||
std::get<1>(CLI::GetParam<TupleType>(identifier)) = std::move(matrix);
|
||||
data::DatasetInfo& di = std::get<0>(CLI::GetParam<TupleType>(identifier));
|
||||
di = data::DatasetInfo(dimensions);
|
||||
|
||||
bool hasCategoricals = false;
|
||||
for (size_t i = 0; i < dimensions; ++i)
|
||||
{
|
||||
if (dims[i])
|
||||
{
|
||||
di.Type(i) = data::Datatype::categorical;
|
||||
hasCategoricals = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Do we need to find how many categories we have?
|
||||
if (hasCategoricals)
|
||||
{
|
||||
arma::vec maxs = arma::max(
|
||||
std::get<1>(CLI::GetParam<TupleType>(identifier)), 1);
|
||||
|
||||
for (size_t i = 0; i < dimensions; ++i)
|
||||
{
|
||||
if (dims[i])
|
||||
{
|
||||
// Map the right number of objects.
|
||||
for (size_t j = 0; j < (size_t) maxs[i]; ++j)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << j;
|
||||
di.MapString<eT>(oss.str(), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer. This function exists to work around Cython's seeming lack
|
||||
* of support for template pointer types.
|
||||
*/
|
||||
template<typename T>
|
||||
T* GetParamPtr(const std::string& paramName)
|
||||
{
|
||||
return CLI::GetParam<T*>(paramName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the matrix part of a matrix + dataset info parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
T& GetParamWithInfo(const std::string& paramName)
|
||||
{
|
||||
// T will be the Armadillo type.
|
||||
typedef std::tuple<data::DatasetInfo, T> TupleType;
|
||||
return std::get<1>(CLI::GetParam<TupleType>(paramName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn verbose output on.
|
||||
*/
|
||||
inline void EnableVerbose()
|
||||
{
|
||||
Log::Info.ignoreInput = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn verbose output off.
|
||||
*/
|
||||
inline void DisableVerbose()
|
||||
{
|
||||
Log::Info.ignoreInput = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable backtraces.
|
||||
*/
|
||||
inline void DisableBacktrace()
|
||||
{
|
||||
Log::Fatal.backtrace = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the status of all timers.
|
||||
*/
|
||||
inline void ResetTimers()
|
||||
{
|
||||
// Just get a new object---removes all old timers.
|
||||
CLI::GetSingleton().timer.Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable timing.
|
||||
*/
|
||||
inline void EnableTimers()
|
||||
{
|
||||
Timer::EnableTiming();
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,46 +0,0 @@
|
||||
/**
|
||||
* @serialization.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Simple utilities for boost::serialization.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_MLPACK_SERIALIZATION_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_MLPACK_SERIALIZATION_HPP
|
||||
|
||||
#include <mlpack/core.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
template<typename T>
|
||||
std::string SerializeOut(T* t, const std::string& name)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
{
|
||||
boost::archive::binary_oarchive b(oss);
|
||||
|
||||
b << boost::serialization::make_nvp(name.c_str(), *t);
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void SerializeIn(T* t, const std::string& str, const std::string& name)
|
||||
{
|
||||
std::istringstream iss(str);
|
||||
boost::archive::binary_iarchive b(iss);
|
||||
|
||||
b >> boost::serialization::make_nvp(name.c_str(), *t);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,123 +0,0 @@
|
||||
/**
|
||||
* @file print_class_defn.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Print the class definition for generating a .pyx binding.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_PRINT_CLASS_DEFN_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_PRINT_CLASS_DEFN_HPP
|
||||
|
||||
#include "strip_type.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Non-serializable models don't require any special definitions, so this prints
|
||||
* nothing.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintClassDefn(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Matrices don't require any special definitions, so this prints nothing.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintClassDefn(
|
||||
const util::ParamData& /* d */,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializable models require a special class definition.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintClassDefn(
|
||||
const util::ParamData& d,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// First, we have to parse the type. If we have something like, e.g.,
|
||||
// 'LogisticRegression<>', we must convert this to 'LogisticRegression[].'
|
||||
std::string strippedType, printedType, defaultsType;
|
||||
StripType(d.cppType, strippedType, printedType, defaultsType);
|
||||
|
||||
/**
|
||||
* This will produce code like:
|
||||
*
|
||||
* cdef class <ModelType>Type:
|
||||
* cdef <ModelType>* modelptr
|
||||
*
|
||||
* def __cinit__(self):
|
||||
* self.modelptr = new <ModelType>()
|
||||
*
|
||||
* def __dealloc__(self):
|
||||
* del self.modelptr
|
||||
*
|
||||
* def __getstate__(self):
|
||||
* return SerializeOut(self.modelptr, "<ModelType>")
|
||||
*
|
||||
* def __setstate__(self, state):
|
||||
* SerializeIn(self.modelptr, state, "<ModelType>")
|
||||
*
|
||||
* def __reduce_ex__(self):
|
||||
* return (self.__class__, (), self.__getstate__())
|
||||
*/
|
||||
std::cout << "cdef class " << strippedType << "Type:" << std::endl;
|
||||
std::cout << " cdef " << printedType << "* modelptr" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " def __cinit__(self):" << std::endl;
|
||||
std::cout << " self.modelptr = new " << printedType << "()" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " def __dealloc__(self):" << std::endl;
|
||||
std::cout << " del self.modelptr" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " def __getstate__(self):" << std::endl;
|
||||
std::cout << " return SerializeOut(self.modelptr, \"" << printedType
|
||||
<< "\")" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " def __setstate__(self, state):" << std::endl;
|
||||
std::cout << " SerializeIn(self.modelptr, state, \"" << printedType
|
||||
<< "\")" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " def __reduce_ex__(self, version):" << std::endl;
|
||||
std::cout << " return (self.__class__, (), self.__getstate__())"
|
||||
<< std::endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the class definition to stdout. Only serializable models require a
|
||||
* different class definition, so anything else does nothing.
|
||||
*
|
||||
* @param d Parameter data.
|
||||
* @param input Unused parameter.
|
||||
* @param output Unused parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintClassDefn(const util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintClassDefn<typename std::remove_pointer<T>::type>(d);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* @file print_defn.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Print the definition of a Python parameter.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_PRINT_DEFN_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_PRINT_DEFN_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Print the definition for a Python binding parameter to stdout. This is the
|
||||
* definition in the function declaration.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintDefn(const util::ParamData& d,
|
||||
const void* /* input */,
|
||||
void* /* output */)
|
||||
{
|
||||
// Make sure that we don't use names that are Python keywords.
|
||||
std::string name = (d.name == "lambda") ? "lambda_" : d.name;
|
||||
|
||||
std::cout << name;
|
||||
if (std::is_same<T, bool>::value)
|
||||
std::cout << "=False";
|
||||
else if (!d.required)
|
||||
std::cout << "=None";
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* @file print_doc.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Print documentation (as part of a docstring) for a Python binding parameter.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_PRINT_DOC_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_PRINT_DOC_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include <mlpack/core/util/hyphenate_string.hpp>
|
||||
#include "get_python_type.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Print the docstring documentation for a given parameter. You are responsible
|
||||
* for setting up the line---this does not handle indentation or anything. This
|
||||
* is meant to produce a line of documentation describing a single parameter.
|
||||
*
|
||||
* The indent parameter (void* input, which should be a pointer to a size_t)
|
||||
* should be passed to know how much to indent for a new line.
|
||||
*
|
||||
* @param d Parameter data struct.
|
||||
* @param input Pointer to size_t containing indent.
|
||||
* @param output Unused parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintDoc(const util::ParamData& d,
|
||||
const void* input,
|
||||
void* /* output */)
|
||||
{
|
||||
const size_t indent = *((size_t*) input);
|
||||
std::ostringstream oss;
|
||||
oss << " - ";
|
||||
if (d.name == "lambda") // Don't print Python keywords.
|
||||
oss << d.name << "_ (";
|
||||
else
|
||||
oss << d.name << " (";
|
||||
oss << GetPythonType<typename std::remove_pointer<T>::type>(d) << "): "
|
||||
<< d.desc;
|
||||
|
||||
// Print a default, if possible.
|
||||
if (!d.required)
|
||||
{
|
||||
if (d.cppType == "std::string")
|
||||
{
|
||||
oss << " Default value '" << boost::any_cast<std::string>(d.value)
|
||||
<< "'.";
|
||||
}
|
||||
else if (d.cppType == "double")
|
||||
{
|
||||
oss << " Default value " << boost::any_cast<double>(d.value) << ".";
|
||||
}
|
||||
else if (d.cppType == "int")
|
||||
{
|
||||
oss << " Default value " << boost::any_cast<int>(d.value) << ".";
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << util::HyphenateString(oss.str(), indent + 4);
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* @file print_doc_functions.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* This file contains functions useful for printing documentation strings
|
||||
* related to Python bindings.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_PRINT_DOC_FUNCTIONS_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_PRINT_DOC_FUNCTIONS_HPP
|
||||
|
||||
#include <mlpack/core/util/hyphenate_string.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Given a parameter type, print the corresponding value.
|
||||
*/
|
||||
template<typename T>
|
||||
inline std::string PrintValue(const T& value, bool quotes);
|
||||
|
||||
// Special overload for booleans.
|
||||
template<>
|
||||
inline std::string PrintValue(const bool& value, bool quotes);
|
||||
|
||||
// Recursion base case.
|
||||
inline std::string PrintInputOptions();
|
||||
|
||||
/**
|
||||
* Print an input option. This will throw an exception if the parameter does
|
||||
* not exist in CLI. For a parameter 'x' with value '5', this will print
|
||||
* something like x=5.
|
||||
*/
|
||||
template<typename T, typename... Args>
|
||||
std::string PrintInputOptions(const std::string& paramName,
|
||||
const T& value,
|
||||
Args... args);
|
||||
|
||||
// Recursion base case.
|
||||
inline std::string PrintOutputOptions();
|
||||
|
||||
template<typename T, typename... Args>
|
||||
std::string PrintOutputOptions(const std::string& paramName,
|
||||
const T& value,
|
||||
Args... args);
|
||||
|
||||
/**
|
||||
* Given a name of a binding and a variable number of arguments (and their
|
||||
* contents), print the corresponding function call.
|
||||
*/
|
||||
template<typename... Args>
|
||||
std::string ProgramCall(const std::string& programName, Args... args);
|
||||
|
||||
/**
|
||||
* Given the name of a model, print it. Here we do not need to modify anything.
|
||||
*/
|
||||
inline std::string PrintModel(const std::string& modelName);
|
||||
|
||||
/**
|
||||
* Given the name of a matrix, print it. Here we do not need to modify
|
||||
* anything.
|
||||
*/
|
||||
inline std::string PrintDataset(const std::string& datasetName);
|
||||
|
||||
/**
|
||||
* Given the parameter name, determine what it would actually be when passed to
|
||||
* the command line.
|
||||
*/
|
||||
inline std::string ParamString(const std::string& paramName);
|
||||
|
||||
/**
|
||||
* Print whether or not we should ignore a check on the given parameter. For
|
||||
* Python bindings, we ignore any checks on output parameters, so if paramName
|
||||
* is an output parameter, this returns true.
|
||||
*/
|
||||
inline bool IgnoreCheck(const std::string& paramName);
|
||||
|
||||
/**
|
||||
* Print whether or not we should ignore a check on the given set of
|
||||
* constraints. For Python bindings, we ignore any checks on output parameters,
|
||||
* so if any parameter is an output parameter, this returns true.
|
||||
*/
|
||||
inline bool IgnoreCheck(const std::vector<std::string>& constraints);
|
||||
|
||||
/**
|
||||
* Print whether or not we should ignore a check on the given set of
|
||||
* constraints. For Python bindings, we ignore any checks on output parameters,
|
||||
* so if any constraint parameter or the main parameter are output parameters,
|
||||
* this returns true.
|
||||
*/
|
||||
inline bool IgnoreCheck(
|
||||
const std::vector<std::pair<std::string, bool>>& constraints,
|
||||
const std::string& paramName);
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
// Include implementation.
|
||||
#include "print_doc_functions_impl.hpp"
|
||||
|
||||
#endif
|
||||
@@ -1,266 +0,0 @@
|
||||
/**
|
||||
* @file print_doc_functions_impl.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* This file contains functions useful for printing documentation strings
|
||||
* related to Python bindings.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_PRINT_DOC_FUNCTIONS_IMPL_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_PRINT_DOC_FUNCTIONS_IMPL_HPP
|
||||
|
||||
#include <mlpack/core/util/hyphenate_string.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Given a parameter type, print the corresponding value.
|
||||
*/
|
||||
template<typename T>
|
||||
inline std::string PrintValue(const T& value, bool quotes)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (quotes)
|
||||
oss << "'";
|
||||
oss << value;
|
||||
if (quotes)
|
||||
oss << "'";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
// Special overload for booleans.
|
||||
template<>
|
||||
inline std::string PrintValue(const bool& value, bool quotes)
|
||||
{
|
||||
if (quotes && value)
|
||||
return "'True'";
|
||||
else if (quotes && !value)
|
||||
return "'False'";
|
||||
else if (!quotes && value)
|
||||
return "True";
|
||||
else
|
||||
return "False";
|
||||
}
|
||||
|
||||
// Recursion base case.
|
||||
std::string PrintInputOptions() { return ""; }
|
||||
|
||||
/**
|
||||
* Print an input option. This will throw an exception if the parameter does
|
||||
* not exist in CLI. For a parameter 'x' with value '5', this will print
|
||||
* something like x=5.
|
||||
*/
|
||||
template<typename T, typename... Args>
|
||||
std::string PrintInputOptions(const std::string& paramName,
|
||||
const T& value,
|
||||
Args... args)
|
||||
{
|
||||
// See if this is part of the program.
|
||||
std::string result = "";
|
||||
if (CLI::Parameters().count(paramName) > 0)
|
||||
{
|
||||
const util::ParamData& d = CLI::Parameters()[paramName];
|
||||
if (d.input)
|
||||
{
|
||||
// Print the input option.
|
||||
std::ostringstream oss;
|
||||
if (paramName != "lambda") // Don't print Python keywords.
|
||||
oss << paramName << "=";
|
||||
else
|
||||
oss << paramName << "_=";
|
||||
oss << PrintValue(value, d.tname == TYPENAME(std::string));
|
||||
result = oss.str();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unknown parameter!
|
||||
throw std::runtime_error("Unknown parameter '" + paramName + "' " +
|
||||
"encountered while assembling documentation! Check PROGRAM_INFO() " +
|
||||
"declaration.");
|
||||
}
|
||||
|
||||
// Continue recursion.
|
||||
std::string rest = PrintInputOptions(args...);
|
||||
if (rest != "" && result != "")
|
||||
result += ", " + rest;
|
||||
else if (result == "")
|
||||
result = rest;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Recursion base case.
|
||||
inline std::string PrintOutputOptions() { return ""; }
|
||||
|
||||
template<typename T, typename... Args>
|
||||
std::string PrintOutputOptions(const std::string& paramName,
|
||||
const T& value,
|
||||
Args... args)
|
||||
{
|
||||
// See if this is part of the program.
|
||||
std::string result = "";
|
||||
if (CLI::Parameters().count(paramName) > 0)
|
||||
{
|
||||
const util::ParamData& d = CLI::Parameters()[paramName];
|
||||
if (!d.input)
|
||||
{
|
||||
// Print a new line for the output option.
|
||||
std::ostringstream oss;
|
||||
oss << ">>> " << value << " = output['" << paramName << "']";
|
||||
result = oss.str();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unknown parameter!
|
||||
throw std::runtime_error("Unknown parameter '" + paramName + "' " +
|
||||
"encountered while assembling documentation! Check PROGRAM_INFO() " +
|
||||
"declaration.");
|
||||
}
|
||||
|
||||
// Continue recursion.
|
||||
std::string rest = PrintOutputOptions(args...);
|
||||
if (rest != "" && result != "")
|
||||
result += '\n';
|
||||
result += rest;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a name of a binding and a variable number of arguments (and their
|
||||
* contents), print the corresponding function call.
|
||||
*/
|
||||
template<typename... Args>
|
||||
std::string ProgramCall(const std::string& programName, Args... args)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << ">>> ";
|
||||
|
||||
// Find out if we have any output options first.
|
||||
std::ostringstream ossOutput;
|
||||
ossOutput << PrintOutputOptions(args...);
|
||||
if (ossOutput.str() != "")
|
||||
oss << "output = ";
|
||||
oss << programName << "(";
|
||||
|
||||
// Now process each input option.
|
||||
oss << PrintInputOptions(args...);
|
||||
oss << ")";
|
||||
|
||||
std::string call = oss.str();
|
||||
oss.str(""); // Reset it.
|
||||
|
||||
// Now process each output option.
|
||||
oss << PrintOutputOptions(args...);
|
||||
if (oss.str() == "")
|
||||
return util::HyphenateString(call, 2);
|
||||
else
|
||||
return util::HyphenateString(call, 2) + "\n" + oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the name of a model, print it. Here we do not need to modify anything.
|
||||
*/
|
||||
inline std::string PrintModel(const std::string& modelName)
|
||||
{
|
||||
return "'" + modelName + "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the name of a matrix, print it. Here we do not need to modify
|
||||
* anything.
|
||||
*/
|
||||
inline std::string PrintDataset(const std::string& datasetName)
|
||||
{
|
||||
return "'" + datasetName + "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the name of a binding, print its invocation.
|
||||
*/
|
||||
inline std::string ProgramCall(const std::string& programName)
|
||||
{
|
||||
return ">>> " + programName + "(";
|
||||
}
|
||||
|
||||
/**
|
||||
* Print any closing call to a program. For a Python binding this is a closing
|
||||
* brace.
|
||||
*/
|
||||
inline std::string ProgramCallClose()
|
||||
{
|
||||
return ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the parameter name, determine what it would actually be when passed to
|
||||
* the command line.
|
||||
*/
|
||||
inline std::string ParamString(const std::string& paramName)
|
||||
{
|
||||
// For a Python binding we don't need to know the type.
|
||||
|
||||
// Make sure that we don't print reserved keywords.
|
||||
if (paramName == "lambda")
|
||||
return "'" + paramName + "_'";
|
||||
else
|
||||
return "'" + paramName + "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the parameter name and an argument, return what should be written as
|
||||
* documentation when referencing that argument.
|
||||
*/
|
||||
template<typename T>
|
||||
inline std::string ParamString(const std::string& paramName, const T& value)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (paramName == "lambda") // Don't print reserved keywords.
|
||||
oss << paramName << "_=" << value;
|
||||
else
|
||||
oss << paramName << "=" << value;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline bool IgnoreCheck(const std::string& paramName)
|
||||
{
|
||||
return !CLI::Parameters()[paramName].input;
|
||||
}
|
||||
|
||||
inline bool IgnoreCheck(const std::vector<std::string>& constraints)
|
||||
{
|
||||
for (size_t i = 0; i < constraints.size(); ++i)
|
||||
{
|
||||
if (!CLI::Parameters()[constraints[i]].input)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool IgnoreCheck(
|
||||
const std::vector<std::pair<std::string, bool>>& constraints,
|
||||
const std::string& paramName)
|
||||
{
|
||||
for (size_t i = 0; i < constraints.size(); ++i)
|
||||
{
|
||||
if (!CLI::Parameters()[constraints[i].first].input)
|
||||
return true;
|
||||
}
|
||||
|
||||
return !CLI::Parameters()[paramName].input;
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,317 +0,0 @@
|
||||
/**
|
||||
* @file print_input_processing.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Print input processing for a Python binding option.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_PRINT_INPUT_PROCESSING_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_PRINT_INPUT_PROCESSING_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include "get_arma_type.hpp"
|
||||
#include "get_numpy_type.hpp"
|
||||
#include "get_numpy_type_char.hpp"
|
||||
#include "get_cython_type.hpp"
|
||||
#include "get_python_type.hpp"
|
||||
#include "strip_type.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Print input processing for a standard option type.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintInputProcessing(
|
||||
const util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
// The copy_all_inputs parameter must be handled first, and therefore is
|
||||
// outside the scope of this code.
|
||||
if (d.name == "copy_all_inputs")
|
||||
return;
|
||||
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
std::string def = "None";
|
||||
if (std::is_same<T, bool>::value)
|
||||
def = "False";
|
||||
|
||||
// Make sure that we don't use names that are Python keywords.
|
||||
std::string name = (d.name == "lambda") ? "lambda_" : d.name;
|
||||
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* # Detect if the parameter was passed; set if so.
|
||||
* if param_name is not None:
|
||||
* SetParam[int](<const string> 'param_name', param_name)
|
||||
* CLI.SetPassed(<const string> 'param_name')
|
||||
*/
|
||||
std::cout << prefix << "# Detect if the parameter was passed; set if so."
|
||||
<< std::endl;
|
||||
if (!d.required)
|
||||
{
|
||||
std::cout << prefix << "if " << name << " is not " << def << ":"
|
||||
<< std::endl;
|
||||
|
||||
std::cout << prefix << " SetParam[" << GetCythonType<T>(d) << "](<const "
|
||||
<< "string> '" << d.name << "', ";
|
||||
if (GetCythonType<T>(d) == "string")
|
||||
std::cout << name << ".encode(\"UTF-8\")";
|
||||
else if (GetCythonType<T>(d) == "vector[string]")
|
||||
std::cout << "[i.encode(\"UTF-8\") for i in " << name << "]";
|
||||
else
|
||||
std::cout << name;
|
||||
std::cout << ")" << std::endl;
|
||||
std::cout << prefix << " CLI.SetPassed(<const string> '" << d.name
|
||||
<< "')" << std::endl;
|
||||
|
||||
// If this parameter is "verbose", then enable verbose output.
|
||||
if (d.name == "verbose")
|
||||
std::cout << prefix << " EnableVerbose()" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << prefix << "SetParam[" << GetCythonType<T>(d) << "](<const "
|
||||
<< "string> '" << d.name << "', ";
|
||||
if (GetCythonType<T>(d) == "string")
|
||||
std::cout << name << ".encode(\"UTF-8\")";
|
||||
else if (GetCythonType<T>(d) == "vector[string]")
|
||||
std::cout << "[i.encode(\"UTF-8\") for i in " << name << "]";
|
||||
else
|
||||
std::cout << name;
|
||||
std::cout << ")" << std::endl;
|
||||
std::cout << prefix << "CLI.SetPassed(<const string> '" << d.name << "')"
|
||||
<< std::endl;
|
||||
}
|
||||
std::cout << std::endl; // Extra line is to clear up the code a bit.
|
||||
}
|
||||
|
||||
/**
|
||||
* Print input processing for a matrix type.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintInputProcessing(
|
||||
const util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* # Detect if the parameter was passed; set if so.
|
||||
* if param_name is not None:
|
||||
* param_name_tuple = to_matrix(param_name)
|
||||
* param_name_mat = arma_numpy.numpy_to_mat_d(param_name_tuple[0],
|
||||
* param_name_tuple[1])
|
||||
* SetParam[mat](<const string> 'param_name', dereference(param_name_mat))
|
||||
* CLI.SetPassed(<const string> 'param_name')
|
||||
*/
|
||||
std::cout << prefix << "# Detect if the parameter was passed; set if so."
|
||||
<< std::endl;
|
||||
if (!d.required)
|
||||
{
|
||||
std::cout << prefix << "if " << d.name << " is not None:" << std::endl;
|
||||
|
||||
std::cout << prefix << " " << d.name << "_tuple = to_matrix(" << d.name
|
||||
<< ", dtype=" << GetNumpyType<typename T::elem_type>() << ", "
|
||||
<< "copy=CLI.HasParam('copy_all_inputs'))" << std::endl;
|
||||
std::cout << prefix << " " << d.name << "_mat = arma_numpy.numpy_to_"
|
||||
<< GetArmaType<T>() << "_" << GetNumpyTypeChar<T>() << "(" << d.name
|
||||
<< "_tuple[0], " << d.name << "_tuple[1])" << std::endl;
|
||||
std::cout << prefix << " SetParam[" << GetCythonType<T>(d) << "](<const "
|
||||
<< "string> '" << d.name << "', dereference(" << d.name << "_mat))"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " CLI.SetPassed(<const string> '" << d.name << "')"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " del " << d.name << "_mat";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << prefix << d.name << "_tuple = to_matrix(" << d.name
|
||||
<< ", dtype=" << GetNumpyType<typename T::elem_type>() << ", "
|
||||
<< "copy=CLI.HasParam('copy_all_inputs'))" << std::endl;
|
||||
std::cout << prefix << d.name << "_mat = arma_numpy.numpy_to_"
|
||||
<< GetArmaType<T>() << "_" << GetNumpyTypeChar<T>() << "(" << d.name
|
||||
<< "_tuple[0], " << d.name << "_tuple[1])" << std::endl;
|
||||
std::cout << prefix << "SetParam[" << GetCythonType<T>(d) << "](<const "
|
||||
<< "string> '" << d.name << "', dereference(" << d.name << "_mat))"
|
||||
<< std::endl;
|
||||
std::cout << prefix << "CLI.SetPassed(<const string> '" << d.name << "')"
|
||||
<< std::endl;
|
||||
std::cout << prefix << "del " << d.name << "_mat";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print input processing for a serializable type.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintInputProcessing(
|
||||
const util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// First, get the correct class name if needed.
|
||||
std::string strippedType, printedType, defaultsType;
|
||||
StripType(d.cppType, strippedType, printedType, defaultsType);
|
||||
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* # Detect if the parameter was passed; set if so.
|
||||
* if param_name is not None:
|
||||
* try:
|
||||
* SetParamPtr[Model]('param_name', (<ModelType?> param_name).modelptr,
|
||||
* CLI.HasParam('copy_all_inputs'))
|
||||
* except TypeError as e:
|
||||
* if type(param_name).__name__ == "ModelType":
|
||||
* SetParamPtr[Model]('param_name', (<ModelType> param_name).modelptr,
|
||||
* CLI.HasParam('copy_all_inputs'))
|
||||
* else:
|
||||
* raise e
|
||||
* CLI.SetPassed(<const string> 'param_name')
|
||||
*/
|
||||
std::cout << prefix << "# Detect if the parameter was passed; set if so."
|
||||
<< std::endl;
|
||||
if (!d.required)
|
||||
{
|
||||
std::cout << prefix << "if " << d.name << " is not None:" << std::endl;
|
||||
std::cout << prefix << " try:" << std::endl;
|
||||
std::cout << prefix << " SetParamPtr[" << strippedType << "]('" << d.name
|
||||
<< "', (<" << strippedType << "Type?> " << d.name << ").modelptr, "
|
||||
<< "CLI.HasParam('copy_all_inputs'))" << std::endl;
|
||||
std::cout << prefix << " except TypeError as e:" << std::endl;
|
||||
std::cout << prefix << " if type(" << d.name << ").__name__ == '"
|
||||
<< strippedType << "Type':" << std::endl;
|
||||
std::cout << prefix << " SetParamPtr[" << strippedType << "]('"
|
||||
<< d.name << "', (<" << strippedType << "Type> " << d.name
|
||||
<< ").modelptr, CLI.HasParam('copy_all_inputs'))" << std::endl;
|
||||
std::cout << prefix << " else:" << std::endl;
|
||||
std::cout << prefix << " raise e" << std::endl;
|
||||
std::cout << prefix << " CLI.SetPassed(<const string> '" << d.name << "')"
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << prefix << "try:" << std::endl;
|
||||
std::cout << prefix << " SetParamPtr[" << strippedType << "]('" << d.name
|
||||
<< "', (<" << strippedType << "Type?> " << d.name << ").modelptr, "
|
||||
<< "CLI.HasParam('copy_all_inputs'))" << std::endl;
|
||||
std::cout << prefix << "except TypeError as e:" << std::endl;
|
||||
std::cout << prefix << " if type(" << d.name << ").__name__ == '"
|
||||
<< strippedType << "Type':" << std::endl;
|
||||
std::cout << prefix << " SetParamPtr[" << strippedType << "]('" << d.name
|
||||
<< "', (<" << strippedType << "Type> " << d.name << ").modelptr, "
|
||||
<< "CLI.HasParam('copy_all_inputs'))" << std::endl;
|
||||
std::cout << prefix << " else:" << std::endl;
|
||||
std::cout << prefix << " raise e" << std::endl;
|
||||
std::cout << prefix << "CLI.SetPassed(<const string> '" << d.name << "')"
|
||||
<< std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print input processing for a matrix/DatasetInfo type.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintInputProcessing(
|
||||
const util::ParamData& d,
|
||||
const size_t indent,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
// The user should pass in a matrix type of some sort.
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
/** We want to generate code like the following:
|
||||
*
|
||||
* if param_name is not None:
|
||||
* param_name_tuple = to_matrix_with_info(param_name)
|
||||
* param_name_mat = arma_numpy.numpy_to_matrix_d(param_name_tuple[0])
|
||||
* SetParamWithInfo[mat](<const string> 'param_name',
|
||||
* dereference(param_name_mat), ¶m_name_tuple[1][0])
|
||||
* CLI.SetPassed(<const string> 'param_name')
|
||||
*/
|
||||
std::cout << prefix << "cdef np.ndarray " << d.name << "_dims" << std::endl;
|
||||
std::cout << prefix << "# Detect if the parameter was passed; set if so."
|
||||
<< std::endl;
|
||||
if (!d.required)
|
||||
{
|
||||
std::cout << prefix << "if " << d.name << " is not None:" << std::endl;
|
||||
std::cout << prefix << " " << d.name << "_tuple = to_matrix_with_info("
|
||||
<< d.name << ", dtype=np.double, copy=CLI.HasParam('copy_all_inputs'))"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " " << d.name << "_mat = arma_numpy.numpy_to_mat_d("
|
||||
<< d.name << "_tuple[0], " << d.name << "_tuple[1])" << std::endl;
|
||||
std::cout << prefix << " " << d.name << "_dims = " << d.name << "_tuple[2]"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " SetParamWithInfo[arma.Mat[double]](<const string>"
|
||||
<< " '" << d.name << "', dereference(" << d.name << "_mat), <const "
|
||||
<< "bool*> " << d.name << "_dims.data)" << std::endl;
|
||||
std::cout << prefix << " CLI.SetPassed(<const string> '" << d.name << "')"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " del " << d.name << "_mat" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << prefix << d.name << "_tuple = to_matrix_with_info(" << d.name
|
||||
<< ", dtype=np.double, copy=CLI.HasParam('copy_all_inputs'))"
|
||||
<< std::endl;
|
||||
std::cout << prefix << d.name << "_mat = arma_numpy.numpy_to_mat_d("
|
||||
<< d.name << "_tuple[0], " << d.name << "_tuple[1])" << std::endl;
|
||||
std::cout << prefix << d.name << "_dims = " << d.name << "_tuple[2]"
|
||||
<< std::endl;
|
||||
std::cout << prefix << "SetParamWithInfo[arma.Mat[double]](<const string>"
|
||||
<< " '" << d.name << "', dereference(" << d.name << "_mat), <const "
|
||||
<< "bool*> " << d.name << "_dims.data)" << std::endl;
|
||||
std::cout << prefix << "CLI.SetPassed(<const string> '" << d.name << "')"
|
||||
<< std::endl;
|
||||
std::cout << prefix << "del " << d.name << "_mat" << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given parameter information and the current number of spaces for indentation,
|
||||
* print the code to process the input to cout. This code assumes that
|
||||
* data.input is true, and should not be called when data.input is false.
|
||||
*
|
||||
* The number of spaces to indent should be passed through the input pointer.
|
||||
*
|
||||
* @param d Parameter data struct.
|
||||
* @param input Pointer to size_t holding the indentation.
|
||||
* @param output Unused parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintInputProcessing(const util::ParamData& d,
|
||||
const void* input,
|
||||
void* /* output */)
|
||||
{
|
||||
PrintInputProcessing<typename std::remove_pointer<T>::type>(d,
|
||||
*((size_t*) input));
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,312 +0,0 @@
|
||||
/**
|
||||
* @file print_output_processing.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Print the output processing in a Python binding .pyx file for a given
|
||||
* parameter.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_PRINT_OUTPUT_PROCESSING_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_PRINT_OUTPUT_PROCESSING_HPP
|
||||
|
||||
#include <mlpack/prereqs.hpp>
|
||||
#include "get_arma_type.hpp"
|
||||
#include "get_numpy_type_char.hpp"
|
||||
#include "get_cython_type.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Print output processing for a regular parameter type.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
const util::ParamData& d,
|
||||
const size_t indent,
|
||||
const bool onlyOutput,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
|
||||
const typename boost::disable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
if (onlyOutput)
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* result = CLI.GetParam[int]('param_name')
|
||||
*/
|
||||
std::cout << prefix << "result = " << "CLI.GetParam[" << GetCythonType<T>(d)
|
||||
<< "](\"" << d.name << "\")";
|
||||
if (GetCythonType<T>(d) == "string")
|
||||
{
|
||||
std::cout << std::endl << prefix << "result = result.decode(\"UTF-8\")";
|
||||
}
|
||||
else if (GetCythonType<T>(d) == "vector[string]")
|
||||
{
|
||||
std::cout << std::endl << prefix
|
||||
<< "result = [x.decode(\"UTF-8\") for x in result]";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* result['param_name'] = CLI.GetParam[int]('param_name')
|
||||
*/
|
||||
std::cout << prefix << "result['" << d.name << "'] = CLI.GetParam["
|
||||
<< GetCythonType<T>(d) << "](\"" << d.name << "\")" << std::endl;
|
||||
if (GetCythonType<T>(d) == "string")
|
||||
{
|
||||
std::cout << prefix << "result['" << d.name << "'] = result['" << d.name
|
||||
<< "'].decode(\"UTF-8\")" << std::endl;
|
||||
}
|
||||
else if (GetCythonType<T>(d) == "vector[string]")
|
||||
{
|
||||
std::cout << prefix << "result['" << d.name << "'] = [x.decode(\"UTF-8\")"
|
||||
<< " for x in result['" << d.name << "']]" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print output processing for a matrix type.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
const util::ParamData& d,
|
||||
const size_t indent,
|
||||
const bool onlyOutput,
|
||||
const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
if (onlyOutput)
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* result = arma_numpy.mat_to_numpy_X(CLI.GetParam[mat]("name"))
|
||||
*
|
||||
* where X indicates the type to convert to.
|
||||
*/
|
||||
std::cout << prefix << "result = arma_numpy." << GetArmaType<T>()
|
||||
<< "_to_numpy_" << GetNumpyTypeChar<T>() << "(CLI.GetParam["
|
||||
<< GetCythonType<T>(d) << "](\"" << d.name << "\"))" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* result['param_name'] =
|
||||
* arma_numpy.mat_to_numpy_X(CLI.GetParam[mat]('name')
|
||||
*
|
||||
* where X indicates the type to convert to.
|
||||
*/
|
||||
std::cout << prefix << "result['" << d.name
|
||||
<< "'] = arma_numpy." << GetArmaType<T>() << "_to_numpy_"
|
||||
<< GetNumpyTypeChar<T>() << "(CLI.GetParam[" << GetCythonType<T>(d)
|
||||
<< "]('" << d.name << "'))" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print output processing for a dataset info / matrix combination.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
const util::ParamData& d,
|
||||
const size_t indent,
|
||||
const bool onlyOutput,
|
||||
const typename boost::enable_if<std::is_same<T,
|
||||
std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
|
||||
{
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
// Print the output with the matrix type. The dimension information doesn't
|
||||
// need to go back.
|
||||
if (onlyOutput)
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* result = arma_numpy.mat_to_numpy_X(GetParamWithInfo[mat]('name'))
|
||||
*/
|
||||
std::cout << prefix << "result = arma_numpy.mat_to_numpy_"
|
||||
<< GetNumpyTypeChar<arma::mat>()
|
||||
<< "(GetParamWithInfo[arma.Mat[double]]('" << d.name << "'))"
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* result['param_name'] =
|
||||
* arma_numpy.mat_to_numpy_X(GetParamWithInfo[mat]('name'))
|
||||
*/
|
||||
std::cout << prefix << "result['" << d.name
|
||||
<< "'] = arma_numpy.mat_to_numpy_" << GetNumpyTypeChar<arma::mat>()
|
||||
<< "(GetParamWithInfo[arma.Mat[double]]('" << d.name << "'))"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print output processing for a serializable model.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintOutputProcessing(
|
||||
const util::ParamData& d,
|
||||
const size_t indent,
|
||||
const bool onlyOutput,
|
||||
const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
|
||||
const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
|
||||
{
|
||||
// Get the type names we need to use.
|
||||
std::string strippedType, printedType, defaultsType;
|
||||
StripType(d.cppType, strippedType, printedType, defaultsType);
|
||||
|
||||
const std::string prefix(indent, ' ');
|
||||
|
||||
if (onlyOutput)
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* result = ModelType()
|
||||
* (<ModelType?> result).modelptr = GetParamPtr[Model]('name')
|
||||
*/
|
||||
std::cout << prefix << "result = " << strippedType << "Type()" << std::endl;
|
||||
std::cout << prefix << "(<" << strippedType << "Type?> result).modelptr = "
|
||||
<< "GetParamPtr[" << strippedType << "]('" << d.name << "')"
|
||||
<< std::endl;
|
||||
|
||||
/**
|
||||
* But we also have to check to ensure there aren't any input model
|
||||
* parameters of the same type that could have the same model pointer.
|
||||
* So we need to loop through all input parameters that have the same type,
|
||||
* and double-check.
|
||||
*/
|
||||
std::map<std::string, util::ParamData>& parameters = CLI::Parameters();
|
||||
for (auto it = parameters.begin(); it != parameters.end(); ++it)
|
||||
{
|
||||
// Is it an input parameter of the same type?
|
||||
const util::ParamData& data = it->second;
|
||||
if (data.input && data.cppType == d.cppType && data.required)
|
||||
{
|
||||
std::cout << prefix << "if (<" << strippedType
|
||||
<< "Type> result).modelptr" << d.name << " == (<" << strippedType
|
||||
<< "Type> " << data.name << ").modelptr:" << std::endl;
|
||||
std::cout << prefix << " (<" << strippedType
|
||||
<< "Type> result).modelptr = <" << strippedType << "*> 0"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " result = " << data.name << std::endl;
|
||||
}
|
||||
else if (data.input && data.cppType == d.cppType)
|
||||
{
|
||||
std::cout << prefix << "if " << data.name << " is not None:"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " if (<" << strippedType
|
||||
<< "Type> result).modelptr" << d.name << " == (<" << strippedType
|
||||
<< "Type> " << data.name << ").modelptr:" << std::endl;
|
||||
std::cout << prefix << " (<" << strippedType
|
||||
<< "Type> result).modelptr = <" << strippedType << "*> 0"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " result = " << data.name << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* This gives us code like:
|
||||
*
|
||||
* result['name'] = ModelType()
|
||||
* (<ModelType?> result['name']).modelptr = GetParamPtr[Model]('name'))
|
||||
*/
|
||||
std::cout << prefix << "result['" << d.name << "'] = " << strippedType
|
||||
<< "Type()" << std::endl;
|
||||
std::cout << prefix << "(<" << strippedType << "Type?> result['" << d.name
|
||||
<< "']).modelptr = GetParamPtr[" << strippedType << "]('" << d.name
|
||||
<< "')" << std::endl;
|
||||
|
||||
/**
|
||||
* But we also have to check to ensure there aren't any input model
|
||||
* parameters of the same type that could have the same model pointer.
|
||||
* So we need to loop through all input parameters that have the same type,
|
||||
* and double-check.
|
||||
*/
|
||||
std::map<std::string, util::ParamData>& parameters = CLI::Parameters();
|
||||
for (auto it = parameters.begin(); it != parameters.end(); ++it)
|
||||
{
|
||||
// Is it an input parameter of the same type?
|
||||
const util::ParamData& data = it->second;
|
||||
if (data.input && data.cppType == d.cppType && data.required)
|
||||
{
|
||||
std::cout << prefix << "if (<" << strippedType << "Type> result['"
|
||||
<< d.name << "']).modelptr == (<" << strippedType << "Type> "
|
||||
<< data.name << ").modelptr:" << std::endl;
|
||||
std::cout << prefix << " (<" << strippedType << "Type> result['"
|
||||
<< d.name << "']).modelptr = <" << strippedType << "*> 0"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " result['" << d.name << "'] = " << data.name
|
||||
<< std::endl;
|
||||
}
|
||||
else if (data.input && data.cppType == d.cppType)
|
||||
{
|
||||
std::cout << prefix << "if " << data.name << " is not None:"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " if (<" << strippedType << "Type> result['"
|
||||
<< d.name << "']).modelptr == (<" << strippedType << "Type> "
|
||||
<< data.name << ").modelptr:" << std::endl;
|
||||
std::cout << prefix << " (<" << strippedType << "Type> result['"
|
||||
<< d.name << "']).modelptr = <" << strippedType << "*> 0"
|
||||
<< std::endl;
|
||||
std::cout << prefix << " result['" << d.name << "'] = " << data.name
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given parameter information and the current number of spaces for indentation,
|
||||
* print the code to process the output to cout. This code assumes that
|
||||
* data.input is false, and should not be called when data.input is true. If
|
||||
* this is the only output, the results will be different.
|
||||
*
|
||||
* The input pointer should be a pointer to a std::tuple<size_t, bool> where the
|
||||
* first element is the indentation and the second element is a boolean
|
||||
* representing whether or not this is the only output parameter.
|
||||
*
|
||||
* @param d Parameter data struct.
|
||||
* @param input Pointer to size_t holding the indentation.
|
||||
* @param output Unused parameter.
|
||||
*/
|
||||
template<typename T>
|
||||
void PrintOutputProcessing(const util::ParamData& d,
|
||||
const void* input,
|
||||
void* /* output */)
|
||||
{
|
||||
std::tuple<size_t, bool>* tuple = (std::tuple<size_t, bool>*) input;
|
||||
|
||||
PrintOutputProcessing<typename std::remove_pointer<T>::type>(d,
|
||||
std::get<0>(*tuple), std::get<1>(*tuple));
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,41 +0,0 @@
|
||||
/**
|
||||
* @file generate_pyx.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Given a list of ParamData structures, emit a .pyx file defining the Cython
|
||||
* binding.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_GENERATE_PYX_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_GENERATE_PYX_HPP
|
||||
|
||||
#include <mlpack/core.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Given a list of parameter definition and program documentation, print a
|
||||
* generated .pyx file to stdout.
|
||||
*
|
||||
* @param parameters List of parameters the program will use (from CLI).
|
||||
* @param programInfo Documentation for the program.
|
||||
* @param mainFilename Filename of the main program (i.e.
|
||||
* "/path/to/pca_main.cpp").
|
||||
* @param functionName Name of the function (i.e. "pca").
|
||||
*/
|
||||
void PrintPYX(const util::ProgramDoc& programInfo,
|
||||
const std::string& mainFilename,
|
||||
const std::string& functionName);
|
||||
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,113 +0,0 @@
|
||||
/**
|
||||
* @file py_option.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* The Python option type.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_PY_OPTION_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_PY_OPTION_HPP
|
||||
|
||||
#include <mlpack/core/util/param_data.hpp>
|
||||
#include "get_param.hpp"
|
||||
#include "get_printable_param.hpp"
|
||||
#include "print_class_defn.hpp"
|
||||
#include "print_defn.hpp"
|
||||
#include "print_doc.hpp"
|
||||
#include "print_input_processing.hpp"
|
||||
#include "print_output_processing.hpp"
|
||||
#include "import_decl.hpp"
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
// Defined in mlpack_main.hpp.
|
||||
extern std::string programName;
|
||||
|
||||
/**
|
||||
* The Python option class.
|
||||
*/
|
||||
template<typename T>
|
||||
class PyOption
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a PyOption object. When constructed, it will register itself
|
||||
* with CLI. The testName parameter is not used and added for compatibility
|
||||
* reasons.
|
||||
*/
|
||||
PyOption(const T defaultValue,
|
||||
const std::string& identifier,
|
||||
const std::string& description,
|
||||
const std::string& alias,
|
||||
const std::string& cppName,
|
||||
const bool required = false,
|
||||
const bool input = true,
|
||||
const bool noTranspose = false,
|
||||
const std::string& /*testName*/ = "")
|
||||
{
|
||||
// Create the ParamData object to give to CLI.
|
||||
util::ParamData data;
|
||||
|
||||
data.desc = description;
|
||||
data.name = identifier;
|
||||
data.tname = TYPENAME(T);
|
||||
data.alias = alias[0];
|
||||
data.wasPassed = false;
|
||||
data.noTranspose = noTranspose;
|
||||
data.required = required;
|
||||
data.input = input;
|
||||
data.loaded = false;
|
||||
// Only "verbose" and "copy_all_inputs" will be persistent.
|
||||
if (identifier == "verbose" || identifier == "copy_all_inputs")
|
||||
data.persistent = true;
|
||||
else
|
||||
data.persistent = false;
|
||||
data.cppType = cppName;
|
||||
|
||||
// Every parameter we'll get from Python will have the correct type.
|
||||
data.value = boost::any(defaultValue);
|
||||
|
||||
// Restore the parameters for this program.
|
||||
if (identifier != "verbose" && identifier != "copy_all_inputs")
|
||||
CLI::RestoreSettings(programName, false);
|
||||
|
||||
// Set the function pointers that we'll need. All of these function
|
||||
// pointers will be used by both the program that generates the pyx, and
|
||||
// also the binding itself. (The binding itself will only use GetParam,
|
||||
// GetPrintableParam, and GetRawParam.)
|
||||
CLI::GetSingleton().functionMap[data.tname]["GetParam"] = &GetParam<T>;
|
||||
CLI::GetSingleton().functionMap[data.tname]["GetPrintableParam"] =
|
||||
&GetPrintableParam<T>;
|
||||
|
||||
// These are used by the pyx generator.
|
||||
CLI::GetSingleton().functionMap[data.tname]["PrintClassDefn"] =
|
||||
&PrintClassDefn<T>;
|
||||
CLI::GetSingleton().functionMap[data.tname]["PrintDefn"] = &PrintDefn<T>;
|
||||
CLI::GetSingleton().functionMap[data.tname]["PrintDoc"] = &PrintDoc<T>;
|
||||
CLI::GetSingleton().functionMap[data.tname]["PrintOutputProcessing"] =
|
||||
&PrintOutputProcessing<T>;
|
||||
CLI::GetSingleton().functionMap[data.tname]["PrintInputProcessing"] =
|
||||
&PrintInputProcessing<T>;
|
||||
CLI::GetSingleton().functionMap[data.tname]["ImportDecl"] = &ImportDecl<T>;
|
||||
|
||||
// Add the ParamData object, then store. This is necessary because we may
|
||||
// import more than one .so that uses CLI, so we have to keep the options
|
||||
// separate. programName is a global variable from mlpack_main.hpp.
|
||||
CLI::Add(std::move(data));
|
||||
if (identifier != "verbose" && identifier != "copy_all_inputs")
|
||||
CLI::StoreSettings(programName);
|
||||
CLI::ClearSettings();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
* @file strip_type.hpp
|
||||
* @author Ryan Curtin
|
||||
*
|
||||
* Given a C++ typename that may have template parameters, return stripped and
|
||||
* printable versions to be used in Python bindings.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#ifndef MLPACK_BINDINGS_PYTHON_STRIP_TYPE_HPP
|
||||
#define MLPACK_BINDINGS_PYTHON_STRIP_TYPE_HPP
|
||||
|
||||
namespace mlpack {
|
||||
namespace bindings {
|
||||
namespace python {
|
||||
|
||||
/**
|
||||
* Given an input type like, e.g., "LogisticRegression<>", return three types
|
||||
* that can be used in Python code. strippedType will be a type with no
|
||||
* template parameters (e.g. "LogisticRegression"), printedType will be a
|
||||
* printable type with the template parameters (e.g. "LogisticRegression[]"),
|
||||
* and defaultsType will be a printable type with a default template parameter
|
||||
* (e.g. "LogisticRegression[T=*]") that can be used for class definitions.
|
||||
*/
|
||||
inline void StripType(const std::string& inputType,
|
||||
std::string& strippedType,
|
||||
std::string& printedType,
|
||||
std::string& defaultsType)
|
||||
{
|
||||
// First, we have to parse the type. If we have something like, e.g.,
|
||||
// 'LogisticRegression<>', we must convert this to 'LogisticRegression[T=*].'
|
||||
printedType = inputType;
|
||||
strippedType = inputType;
|
||||
defaultsType = inputType;
|
||||
if (printedType.find("<") != std::string::npos)
|
||||
{
|
||||
// Are there any template parameters? Or is it the default?
|
||||
const size_t loc = printedType.find("<>");
|
||||
if (loc != std::string::npos)
|
||||
{
|
||||
// Convert it from "<>".
|
||||
strippedType.replace(loc, 2, "");
|
||||
printedType.replace(loc, 2, "[]");
|
||||
defaultsType.replace(loc, 2, "[T=*]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace python
|
||||
} // namespace bindings
|
||||
} // namespace mlpack
|
||||
|
||||
#endif
|
||||
Loaded 100 of 930 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user