GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tinyflow/include/tinyflow/base.h at master · tqchen/tinyflow

This repository was archived by the owner on Jan 20, 2020. It is now read-only.

Expand file tree

/

base.h

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
124 lines (110 loc) · 3.21 KB
/

base.h

Copy path

File metadata and controls

124 lines (110 loc) · 3.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*!
* Copyright (c) 2016 by Contributors
* \file base.h
* \brief Basic data structures.
*/
#ifndef TINYFLOW_BASE_H_
#define TINYFLOW_BASE_H_
#include <nnvm/base.h>
#include <nnvm/node.h>
#include <nnvm/tuple.h>
#include <nnvm/graph.h>
#include <nnvm/symbolic.h>
#include <vector>
#include <string>
namespace tinyflow {
using nnvm::Op;
using nnvm::Node;
using nnvm::Symbol;
using nnvm::TShape;
/*! \brief device mask for each device */
enum DeviceMask {
kCPU = 1,
kGPU = 2
};
/*! \brief data type enumeration */
enum DataType {
kFloat32 = 0
};
/*! \brief contiguous tensor block data structure */
struct TBlob {
/*! \brief pointer to the data */
void* data{nullptr};
/*! \brief shape of the tensor */
TShape shape;
/*! \brief device mask of the corresponding device type */
int dev_mask{kCPU};
/*! \brief type of the tensor */
int dtype{kFloat32};
};
/*!
* \brief a lua function to return closure to carry out computation of an op.
*
* Signature:
* function(inputs, outputs, kwarg)
* - inputs: array of input torch.FloatTensor
* - outputs: array of input torch.FloatTensor
* - kwargs: additional table arguments passed from kwarg.
* - return: a lua closure, with signature function() that carrys out the computation.
*
* After this function, outputs content are set to be correct value.
* This function cannot change the storage of inputs and outputs.
* \note Register as FLuaCompute
* only one of FLuaCreateNNModule/FLuaCompute is needed.
*/
using FLuaCompute = std::string;
/*!
* \brief a lua code to create a NN module/Criterion for an op.
* Only allows register normal module that takes one tensor and returns one tensor.
*
* Signature:
* function(ishape, kwarg)
* - ishape: array of array, shape of input arguments, including weights
* - kwarg: table: str->str, additional arguments to the op.
* - return: a nn.Module for corresponding op.
*
* \note Register as FLuaCreateNNModule,
* only one of FLuaCreateNNModule/FLuaCompute is needed.
*/
using FLuaCreateNNModule = std::string;
/*!
* \brief If registered and TBackwardNumNoGrad=k
* The last k inputs do not have gradient.
* \note Register as TBackwardNumNoGradInputs
*/
using TBackwardNumNoGradInputs = int;
/*!
* \brief Whether backward need weight.
* \note Register as TBackwardNeedInputs
*/
using TBackwardNeedInputs = bool;
/*!
* \brief Whether backward op need outputs.
* \note Register as TBackwardNeedOutputs
*/
using TBackwardNeedOutputs = bool;
/*! \brief Executor of a graph */
class Session {
public:
/*!
* \brief Run the given graph
* \param g the graph to run.
* \param inputs The input feed_dict mapping
* \note The session hold the ownership of the outputs.
* The results are only valid before calling any functions of this session again.
* \return The output tensors.
*/
virtual const std::vector<TBlob>& Run(
Symbol* g,
const std::unordered_map<std::string, TBlob>& inputs) = 0;
/*! \brief virtual destructor */
virtual ~Session() {}
/*!
* \brief create a new session of given type.
* \param type The type of the session.
* \return a new created session.
*/
static Session* Create(const std::string& type);
};
} // namespace tinyflow
#endif // TINYFLOW_BASE_H_
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.