예제 #1
0
    def _append_ops(self, block):
        op_proto = OpProtoHolder.instance().get_op_proto(self.op_type)
        "infer datatype from inputs and outputs for this test case"
        self.infer_dtype_from_inputs_outputs(self.inputs, self.outputs)
        inputs = append_input_output(block, op_proto, self.inputs, True,
                                     self.dtype)
        outputs = append_input_output(block, op_proto, self.outputs, False,
                                      self.dtype)

        if hasattr(self, "cache_name_list"):
            for name in self.cache_name_list:
                inputs[name] = block.create_var(name=name,
                                                persistable=True,
                                                type=core.VarDesc.VarType.RAW,
                                                stop_gradient=True)

        op = block.append_op(
            type=self.op_type,
            inputs=inputs,
            outputs=outputs,
            attrs=self.attrs if hasattr(self, "attrs") else dict())
        # infer variable type and infer shape in compile-time
        op.desc.infer_var_type(block.desc)
        op.desc.infer_shape(block.desc)

        return op
예제 #2
0
 def _append_ops(self, block):
     op_proto = OpProtoHolder.instance().get_op_proto(self.op_type)
     "infer datatype from inputs and outputs for this test case"
     self.infer_dtype_from_inputs_outputs(self.inputs, self.outputs)
     inputs = append_input_output(block, op_proto, self.inputs, True,
                                  self.dtype)
     outputs = append_input_output(block, op_proto, self.outputs, False,
                                   self.dtype)
     op = block.append_op(
         type=self.op_type,
         inputs=inputs,
         outputs=outputs,
         attrs=self.attrs if hasattr(self, "attrs") else dict())
     # infer variable type and infer shape in compile-time
     op.desc.infer_var_type(block.desc)
     op.desc.infer_shape(block.desc)