Ejemplo n.º 1
0
void	replace_field(int position, int color, t_core *core)
{
	int i;

	if (!(if_dim_exists(core->vis.dim, position, color)))
		add_dim(&core->vis.dim, new_dim(position, color));
	i = 4;
	while (i > 0)
	{
		i--;
		get_position((position + i) % MEM_SIZE, color, core);
	}
}
Ejemplo n.º 2
0
NcDim* NcFile::add_dim(NcToken name)
{
    return add_dim(name, NC_UNLIMITED);
}
Ejemplo n.º 3
0
ExprSub::ExprSub(const ExprNode& left, const ExprNode& right) :
				ExprBinaryOp(left,right,add_dim((Dim&) left.dim, (Dim&) right.dim)) {
}
Ejemplo n.º 4
0
dim_vector::iterator netcdf::add_dim(std::string const & name, int32_t dim_length, int32_t default_dim_length) {
    return add_dim(dim(name, dim_length), default_dim_length);
}
Ejemplo n.º 5
0
Archivo: defs.cpp Proyecto: Shrsh/CNTK
std::function<void(OpSchema&)> ArgReduceDocGenerator(const char* name) {
  return [=](OpSchema& schema) {
    std::string doc = R"DOC(
Computes the indices of the {name} elements of the input tensor's element along the 
provided axis. The resulted tensor has the same rank as the input if keepdims equal 1.
If keepdims equal 0, then the resulted tensor have the reduced dimension pruned. 
The type of the output tensor is integer.)DOC";
    ReplaceAll(doc, "{name}", name);
    schema.SetDoc(doc.c_str());
    schema.Attr(
        "axis",
        "The axis in which to compute the arg indices. Default is 0.",
        AttributeProto::INT,
        static_cast<int64_t>(0));
    schema.Attr(
        "keepdims",
        "Keep the reduced dimension or not, default 1 mean keep reduced dimension.",
        AttributeProto::INT,
        static_cast<int64_t>(1));
    schema.Input(0, "data", "An input tensor.", "T");
    schema.Output(
        0,
        "reduced",
        "Reduced output tensor with integer data type.",
        "tensor(int64)");
    schema.TypeConstraint(
        "T",
        OpSchema::all_numeric_types(),
        "Constrain input and output types to all numeric tensors.");
    schema.TypeAndShapeInferenceFunction([](InferenceContext& ctx) {
      // set output element type to int64
      updateOutputElemType(ctx, 0, TensorProto_DataType_INT64);

      if (!hasNInputShapes(ctx, 1)) {
        return;
      }

      auto& input_shape = ctx.getInputType(0)->tensor_type().shape();
      auto output_shape =
          ctx.getOutputType(0)->mutable_tensor_type()->mutable_shape();
      int64_t input_ndim = input_shape.dim_size();
      int64_t axis = 0; // default to 0
      auto axis_proto = ctx.getAttribute("axis");
      if (axis_proto) {
        axis = axis_proto->i();
        if (axis < 0)
          axis += input_ndim;
      }

      int64_t keep_dims = 1;
      auto attr_proto = ctx.getAttribute("keepdims");
      if (attr_proto) {
        keep_dims = attr_proto->i();
      }
      // do we need handle negative axis?
      for (int i = 0; i < input_ndim; ++i) {
        if (i != axis) {
          auto dim = output_shape->add_dim();
          dim->CopyFrom(input_shape.dim(i));
        } else {
          if (keep_dims == 1) {
            auto dim = output_shape->add_dim();
            dim->set_dim_value(1);
          }
        }
      }
    });
  };
Ejemplo n.º 6
0
void TestDim::add() {
	Dim sca;
	Dim row(Dim::row_vec(3));
	Dim col(Dim::col_vec(3));
	Dim mat(Dim::matrix(3,3));

	CPPUNIT_ASSERT(add_dim(sca,sca)==Dim::scalar());
	CPPUNIT_ASSERT(add_dim(row,row)==Dim::row_vec(3));
	CPPUNIT_ASSERT(add_dim(col,col)==Dim::col_vec(3));
	CPPUNIT_ASSERT(add_dim(mat,mat)==Dim::matrix(3,3));

	CPPUNIT_ASSERT_THROW(add_dim(sca,col),DimException);
	CPPUNIT_ASSERT_THROW(add_dim(sca,row),DimException);
	CPPUNIT_ASSERT_THROW(add_dim(sca,mat),DimException);

	CPPUNIT_ASSERT_THROW(add_dim(col,sca),DimException);
	CPPUNIT_ASSERT_THROW(add_dim(col,row),DimException);
	CPPUNIT_ASSERT_THROW(add_dim(col,mat),DimException);

	CPPUNIT_ASSERT_THROW(add_dim(row,sca),DimException);
	CPPUNIT_ASSERT_THROW(add_dim(row,col),DimException);
	CPPUNIT_ASSERT_THROW(add_dim(row,mat),DimException);

	CPPUNIT_ASSERT_THROW(add_dim(mat,sca),DimException);
	CPPUNIT_ASSERT_THROW(add_dim(mat,col),DimException);
	CPPUNIT_ASSERT_THROW(add_dim(mat,row),DimException);
}