TemporaryVariable

English | 简体中文

Product Support Status

Product Supported
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products √
Atlas inference products √
Atlas training products √

Function Description

Creates a temporary variable tensor. After TemporaryVariable is used, the reference to the variable tensor must be passed to the paired DestroyTemporaryVariable operator for destruction. The shape and data type of the output tensor y are inferred based on the shape and dtype attributes: the output shape is the same as the shape attribute, and the output data type is the same as the dtype attribute.

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
shape Attribute Required. The shape of the variable tensor. ListInt -
dtype Attribute Required. The data type of elements in the variable tensor. Int -
var_name Attribute Optional. The name of the variable to create. String, with the default value of "" -
y Output The created variable tensor, whose shape is the same as the shape attribute and whose data type is the same as the dtype attribute. TensorType::ALL() ND

Constraint Description

  • This operator is an experimental feature (EXPERIMENTAL). Do not use it in the production environment.
  • This operator is a TensorFlow-compatible operator, and the graph engine registers it as a node (GeDeletedOp) to be eliminated in the graph optimization phase: in a real TensorFlow graph, the framework parser pairs it with DestroyTemporaryVariable and processes it in the parsing phase. Therefore, this operator cannot be compiled and executed independently through RunGraph/BuildModel.

Invocation Description

The TemporaryVariable operator is a basic graph engine operator, and is used in pairs with DestroyTemporaryVariable: this operator creates a temporary variable for downstream writing, and DestroyTemporaryVariable reads the final value and destroys the temporary variable after all uses are completed.

Invocation Method Invocation Sample Description
Graph-mode invocation test_geir_temporary_variable Invokes the TemporaryVariable operator by building a graph through the operator IR.