DLPrimitives
pointwise.hpp
1 #pragma once
2 #include <dlprim/tensor.hpp>
3 #include <dlprim/context.hpp>
4 namespace dlprim {
5 namespace core {
6 
10  void bind_as_dtype(cl::Kernel &k,int &p,double value,DataType dt);
19  void pointwise_operation(std::vector<Tensor> xs,
20  std::vector<Tensor> ys,
21  std::vector<double> ws,
22  std::string const &code,
23  ExecutionContext const &ec);
27  void pointwise_operation_broadcast( std::vector<Tensor> xs,
28  std::vector<Tensor> ys,
29  std::vector<double> ws,
30  std::string const &code,
31  ExecutionContext const &e);
32 
46  public:
47 
52  virtual size_t workspace() = 0;
58  // \param parameters - the weight paramerters, size should match weights_count
63  virtual void enqueue(std::vector<Tensor> xs,
64  std::vector<Tensor> ys,
66  std::vector<double> parameters,
67  std::vector<double> alpha,
68  std::vector<double> beta,
69  ExecutionContext const &e) = 0;
70 
76  // \param weights_count - size of parameters vector in enqueue
85  static std::unique_ptr<PointwiseOperationBroadcastReduce> create(
86  Context &ctx,
87  std::vector<TensorSpecs> xs,
88  std::vector<TensorSpecs> ys,
89  int weights_count,DataType weights_type,
90  std::string const &compute_code,
91  std::string const &reduce_init,
92  std::string const &reduce);
93 
94  };
95 
96 } // core
97 } // dlprim
void pointwise_operation(std::vector< Tensor > xs, std::vector< Tensor > ys, std::vector< double > ws, std::string const &code, ExecutionContext const &ec)
per form operations function(xs,ws)->yw such that each tensor in xs and ys has same shape...
This is main object that represent the pair of OpenCL platform and device all other objects use it...
Definition: context.hpp:302
virtual size_t workspace()=0
Get size of workspace in bytes needed.
DataType
type definition
Definition: definitions.hpp:69
Perform pointwise operation with both boradcasting and reduction.
Definition: pointwise.hpp:45
virtual void enqueue(std::vector< Tensor > xs, std::vector< Tensor > ys, Tensor &workspace, std::vector< double > parameters, std::vector< double > alpha, std::vector< double > beta, ExecutionContext const &e)=0
Perform coputations.
void pointwise_operation_broadcast(std::vector< Tensor > xs, std::vector< Tensor > ys, std::vector< double > ws, std::string const &code, ExecutionContext const &e)
Similar to pointwise_operation but xs are broadcasted numpy style. ys must much broadcasted shape...
void bind_as_dtype(cl::Kernel &k, int &p, double value, DataType dt)
Bind a parameter to kernet casting it to apropriate opencl type dt.
Mane namespace.
Definition: context.hpp:9
Central Data Contrainer - Tensor.
Definition: tensor.hpp:99
static std::unique_ptr< PointwiseOperationBroadcastReduce > create(Context &ctx, std::vector< TensorSpecs > xs, std::vector< TensorSpecs > ys, int weights_count, DataType weights_type, std::string const &compute_code, std::string const &reduce_init, std::string const &reduce)
Create objects:
This class is used to pass cl::Events that the kernel should wait for and/or signal event completion...
Definition: context.hpp:121