File: structural_svm_problem_threaded_abstract.h

package info (click to toggle)
mldemos 0.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 32,224 kB
  • ctags: 46,525
  • sloc: cpp: 306,887; ansic: 167,718; ml: 126; sh: 109; makefile: 2
file content (64 lines) | stat: -rw-r--r-- 2,218 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (C) 2011  Davis E. King (davis@dlib.net)
// License: Boost Software License   See LICENSE.txt for the full license.
#undef DLIB_STRUCTURAL_SVM_PRObLEM_THREADED_ABSTRACT_H__
#ifdef DLIB_STRUCTURAL_SVM_PRObLEM_THREADED_ABSTRACT_H__

#include "structural_svm_problem_abstract.h"
#include "../matrix.h"

namespace dlib
{

// ----------------------------------------------------------------------------------------

    template <
        typename matrix_type_,
        typename feature_vector_type_ = matrix_type_
        >
    class structural_svm_problem_threaded : public structural_svm_problem<matrix_type_,feature_vector_type_> 
    {
    public:
        /*!
            WHAT THIS OBJECT REPRESENTS
                This object is identical to the structural_svm_problem object defined in 
                dlib/svm/structural_svm_problem_abstract.h except that its constructor
                takes a number which defines how many threads will be used to make concurrent
                calls to the separation_oracle() routine.  

                So this object lets you take advantage of a multi-core system.  You should
                set the num_threads parameter equal to the number of available cores.  Note
                that the separation_oracle() function which you provide must be thread safe
                if you are to use this version of the structural_svm_problem.
        !*/

        typedef matrix_type_ matrix_type;
        typedef typename matrix_type::type scalar_type;
        typedef feature_vector_type_ feature_vector_type;

        structural_svm_problem (
            unsigned long num_threads
        );
        /*!
            ensures
                - this object is properly initialized
                - #get_num_threads() == num_threads
        !*/

        unsigned long get_num_threads (
        ) const; 
        /*!
            ensures
                - Returns the number of threads which will be used to make concurrent
                  calls to the separation_oracle() function.
        !*/

    };

// ----------------------------------------------------------------------------------------

}

#endif // DLIB_STRUCTURAL_SVM_PRObLEM_THREADED_ABSTRACT_H__