Exemplo n.º 1
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pipeline interface
int SQY_PipelineEncode_UI8(const char* pipeline,
                            const char* src,
                            long* shape,
                            unsigned shape_size ,
                            char* dst,
                            long* dstlength,
                            int nthreads)
{

  int value =1;
  if(!sqy::dypeline<std::uint8_t>::can_be_built_from(pipeline))
    return value;


  std::vector<std::size_t> shape_(shape, shape+shape_size);
  auto pipe = sqy::dypeline<std::uint8_t>::from_string(pipeline);
  if(pipe.empty()){
    std::cerr << "[sqeazy]\t received " << pipe.name() << "pipeline of size 0, cannot encode buffer\n";
    return value;
  }

  pipe.set_n_threads(nthreads);

  char* encoded_end = pipe.encode(reinterpret_cast<const std::uint8_t*>(src),
                                  dst,
                                  shape_);

  if(!encoded_end)
    return value;
  else
    value = 0;

  *dstlength = encoded_end - dst;
  return value;
}
Exemplo n.º 2
0
 ArrayStore(T* p, const TinyVector<int, Rank>& s) :
 ptr_(p),
 owner_(std::tr1::shared_ptr<T>(p,ArrayDeleter<T>())),
 shape_(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
 rank_(s.length()) {
     for (int i = 0; i < Rank; ++i)
         shape_(i) = s(i);
 }
Exemplo n.º 3
0
 ArrayStore(Array<T, Rank> &a) :
 ptr_(a.data()),
 owner_(a),
 shape_(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
 rank_(a.rank()) {
     for (int i = 0; i < Rank; ++i)
         shape_(i) = a.extent(i);
 }
Exemplo n.º 4
0
ndarray from_data_impl(void * data,
		       dtype const & dt,
		       Container shape,
		       Container strides,
		       python::object const & owner,
		       bool writeable,
		       typename boost::enable_if< boost::is_integral<typename Container::value_type> >::type * enabled = NULL)
{
  std::vector<Py_intptr_t> shape_(shape.begin(),shape.end());
  std::vector<Py_intptr_t> strides_(strides.begin(), strides.end());
  return from_data_impl(data, dt, shape_, strides_, owner, writeable);    
}
Exemplo n.º 5
0
        Array<U, Rank>
        copy_array() {
            if (Rank != rank_)
                throw das::bad_array_size();
            
            size_t s = size();
            
            U* data = new U[s];
            for(size_t j=0; j<s;++j)
                data[j] = ptr_[j];
            
            TinyVector<int, Rank> shape;
            for (int i = 0; i < Rank; ++i)
                shape(i) = shape_(i);

            return Array<U,Rank>(data,shape,deleteDataWhenDone);
        }
Exemplo n.º 6
0
ndarray from_data_impl(void * data,
		       dtype const & dt,
		       python::object const & shape,
		       python::object const & strides,
		       python::object const & owner,
		       bool writeable)
{
  std::vector<Py_intptr_t> shape_(len(shape));
  std::vector<Py_intptr_t> strides_(len(strides));
  if (shape_.size() != strides_.size())
  {
    PyErr_SetString(PyExc_ValueError, "Length of shape and strides arrays do not match.");
    python::throw_error_already_set();
  }
  for (std::size_t i = 0; i < shape_.size(); ++i)
  {
    shape_[i] = python::extract<Py_intptr_t>(shape[i]);
    strides_[i] = python::extract<Py_intptr_t>(strides[i]);
  }
  return from_data_impl(data, dt, shape_, strides_, owner, writeable);
}
Exemplo n.º 7
0
 size_t size() const {
     size_t s = 1;
     for (int i = 0; i < 11; ++i)
         s *= shape_(i);
     return s;
 }