Skip to content

Commit

Permalink
0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Viacheslav Seledkin committed Apr 25, 2018
1 parent d4588d3 commit b19906c
Show file tree
Hide file tree
Showing 3 changed files with 799 additions and 625 deletions.
11 changes: 9 additions & 2 deletions artm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"fmt"
"math/rand"
"unsafe"
"time"

"github.com/golang/protobuf/proto"
)

// #cgo darwin LDFLAGS: -L. -lstdc++ -lm -lboost_system -lboost_thread-mt -lboost_iostreams -lboost_filesystem -lartm-static -lgflags -lgoogle-glog -linternals_proto -lmessages_proto -lprotobuf -lprotobuf-lite -lprotoc
// #cgo darwin LDFLAGS: -L. -lstdc++ -lm -lboost_system -lboost_timer -lboost_thread-mt -lboost_iostreams -lboost_filesystem -lartm-static -lgflags -lgoogle-glog -linternals_proto -lmessages_proto -lprotobuf -lprotobuf-lite -lprotoc
// #cgo linux LDFLAGS: -L. -lstdc++ -lm -lboost_system -lboost_thread -lboost_iostreams -lboost_filesystem -lartm-static -lgoogle-glog -lgflags -linternals_proto -lmessages_proto -lprotobuf -lprotobuf-lite -lprotoc
// #include <stdlib.h>
// #include "c_interface.h"
Expand All @@ -29,6 +30,10 @@ var ARTM_ERRORS = []string{
"ARTM_DISK_WRITE_ERROR",
}

func init() {
rand.Seed(time.Now().UTC().UnixNano())
}

func NewGetThetaMatrixArgs() *GetThetaMatrixArgs {
eps := Default_GetThetaMatrixArgs_Eps
layout := Default_GetThetaMatrixArgs_MatrixLayout
Expand Down Expand Up @@ -437,7 +442,9 @@ func ArtmRequestThetaMatrix(masterModelID int, conf *GetThetaMatrixArgs) (*Theta
if err != nil {
return nil, err
}

if messageLength == 0 {
return nil, fmt.Errorf("ThetaMatrix is empty")
}
thetaMatrix := &ThetaMatrix{}
if err = artmCopyRequestedMessage(messageLength, thetaMatrix); err != nil {
return nil, err
Expand Down
56 changes: 12 additions & 44 deletions c_interface.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
// All methods must be inside "extern "C"" scope. All complex data structures should be passed in
// as Google Protobuf Messages, defined in messages.proto.

#ifndef SRC_ARTM_C_INTERFACE_H_
#define SRC_ARTM_C_INTERFACE_H_
#pragma once

#include <stdint.h>

Expand All @@ -18,22 +17,18 @@
#else
#define DLL_PUBLIC
#endif

#ifdef __cplusplus
extern "C" {
#endif

DLL_PUBLIC int64_t ArtmDuplicateMasterComponent(int master_id, int64_t length, const char* duplicate_master_args);

//Wrapper available
DLL_PUBLIC int64_t ArtmDuplicateMasterComponent(int master_id, int64_t length, const char* duplicate_master_args);
DLL_PUBLIC int64_t ArtmCreateMasterModel(int64_t length, const char* master_model_config);
//Wrapper available
DLL_PUBLIC int64_t ArtmReconfigureMasterModel(int master_id, int64_t length, const char* master_model_config);
DLL_PUBLIC int64_t ArtmReconfigureTopicName(int master_id, int64_t length, const char* master_model_config);

//Wrapper available
DLL_PUBLIC int64_t ArtmDisposeMasterComponent(int master_id);

//Wrapper available
DLL_PUBLIC int64_t ArtmDisposeModel(int master_id, const char* model_name);

DLL_PUBLIC int64_t ArtmClearThetaCache(int master_id, int64_t length, const char* clear_theta_cache_args);
Expand All @@ -44,39 +39,26 @@ extern "C" {
DLL_PUBLIC int64_t ArtmReconfigureRegularizer(int master_id, int64_t length, const char* regularizer_config);
DLL_PUBLIC int64_t ArtmDisposeRegularizer(int master_id, const char* regularizer_name);

// Wrapper available
DLL_PUBLIC int64_t ArtmGatherDictionary(int master_id, int64_t length, const char* gather_dictionary_args);
// Wrapper available
DLL_PUBLIC int64_t ArtmFilterDictionary(int master_id, int64_t length, const char* filter_dictionary_args);
DLL_PUBLIC int64_t ArtmCreateDictionary(int master_id, int64_t length, const char* dictionary_data);
DLL_PUBLIC int64_t ArtmCreateDictionaryNamed(int master_id, int64_t length, const char* dictionary_data, const char* name);

//Wrapper available
DLL_PUBLIC int64_t ArtmCreateDictionaryNamed(int master_id, int64_t length,
const char* dictionary_data, const char* name);
DLL_PUBLIC int64_t ArtmRequestDictionary(int master_id, int64_t length, const char* request_dictionary_args);
//Wrapper available
DLL_PUBLIC int64_t ArtmDisposeDictionary(int master_id, const char* dictionary_name);

//Wrapper available
DLL_PUBLIC int64_t ArtmImportDictionary(int master_id, int64_t length, const char* import_dictionary_args);
//Wrapper available
DLL_PUBLIC int64_t ArtmExportDictionary(int master_id, int64_t length, const char* export_dictionary_args);
DLL_PUBLIC int64_t ArtmParseCollection(int64_t length, const char* collection_parser_config);

DLL_PUBLIC int64_t ArtmImportBatches(int master_id, int64_t length, const char* import_batches_args);


//Wrapper available
DLL_PUBLIC int64_t ArtmDisposeBatch(int master_id, const char* batch_name);

DLL_PUBLIC int64_t ArtmOverwriteTopicModel(int master_id, int64_t length, const char* topic_model);
DLL_PUBLIC int64_t ArtmOverwriteTopicModelNamed(int master_id, int64_t length,
const char* topic_model, const char* name);
//Wrapper available
DLL_PUBLIC int64_t ArtmInitializeModel(int master_id, int64_t length, const char* init_model_args);
//Wrapper available
DLL_PUBLIC int64_t ArtmExportModel(int master_id, int64_t length, const char* export_model_args);

//Wrapper available
DLL_PUBLIC int64_t ArtmImportModel(int master_id, int64_t length, const char* import_model_args);
DLL_PUBLIC int64_t ArtmAttachModel(int master_id, int64_t length, const char* attach_model_args,
int64_t address_length, char* address);
Expand All @@ -88,58 +70,44 @@ extern "C" {
DLL_PUBLIC int64_t ArtmRegularizeModel(int master_id, int64_t length, const char* regularize_model_args);
DLL_PUBLIC int64_t ArtmNormalizeModel(int master_id, int64_t length, const char* normalize_model_args);

//Wrapper available
DLL_PUBLIC int64_t ArtmFitOfflineMasterModel(int master_id, int64_t length,
const char* fit_offline_master_model_args);
const char* fit_offline_master_model_args);
DLL_PUBLIC int64_t ArtmFitOnlineMasterModel(int master_id, int64_t length, const char* fit_online_master_model_args);

//Wrapper available
DLL_PUBLIC int64_t ArtmRequestTransformMasterModel(int master_id, int64_t length,
const char* transform_master_model_args);
//Wrapper available
DLL_PUBLIC int64_t ArtmRequestTransformMasterModelExternal(int master_id, int64_t length,
const char* transform_master_model_args);

DLL_PUBLIC int64_t ArtmRequestMasterModelConfig(int master_id);

//Wrapper available
DLL_PUBLIC int64_t ArtmRequestThetaMatrix(int master_id, int64_t length, const char* get_theta_args);
//Wrapper available
DLL_PUBLIC int64_t ArtmRequestThetaMatrixExternal(int master_id, int64_t length, const char* get_theta_args);

//Wrapper available
DLL_PUBLIC int64_t ArtmRequestTopicModel(int master_id, int64_t length, const char* get_model_args);

//Wrapper available
DLL_PUBLIC int64_t ArtmRequestTopicModelExternal(int master_id, int64_t length, const char* get_model_args);

//Wrapper available
DLL_PUBLIC int64_t ArtmRequestScore(int master_id, int64_t length, const char* get_score_args);

DLL_PUBLIC int64_t ArtmRequestScoreArray(int master_id, int64_t length, const char* get_score_args);

//Wrapper available
DLL_PUBLIC int64_t ArtmRequestMasterComponentInfo(int master_id, int64_t length, const char* get_master_info_args);
DLL_PUBLIC int64_t ArtmExportScoreTracker(int master_id, int64_t length, const char* export_score_tracker_args);
DLL_PUBLIC int64_t ArtmImportScoreTracker(int master_id, int64_t length, const char* import_score_tracker_args);

//Wrapper available
DLL_PUBLIC int64_t ArtmRequestMasterComponentInfo(int master_id, int64_t length, const char* get_master_info_args);
DLL_PUBLIC int64_t ArtmRequestLoadBatch(const char* filename);
DLL_PUBLIC int64_t ArtmCopyRequestedMessage(int64_t length, char* address);
DLL_PUBLIC int64_t ArtmCopyRequestedObject(int64_t length, char* address);

DLL_PUBLIC int64_t ArtmAwaitOperation(int operation_id, int64_t length, const char* await_operation_args);
//Wrapper available
DLL_PUBLIC int64_t ArtmSaveBatch(const char* disk_path, int64_t length, const char* batch);

//Wrapper available
DLL_PUBLIC int64_t ArtmSaveBatch(const char* disk_path, int64_t length, const char* batch);
DLL_PUBLIC const char* ArtmGetLastErrorMessage();

DLL_PUBLIC const char* ArtmGetVersion();
DLL_PUBLIC int64_t ArtmConfigureLogging(int64_t length, const char* configure_logging_args);

DLL_PUBLIC int64_t ArtmSetProtobufMessageFormatToJson();
DLL_PUBLIC int64_t ArtmSetProtobufMessageFormatToBinary();
DLL_PUBLIC int64_t ArtmProtobufMessageFormatIsJson();

#ifdef __cplusplus
}
#endif
#endif // SRC_ARTM_C_INTERFACE_H_

Loading

0 comments on commit b19906c

Please sign in to comment.