/*******************************************************************************
 * Copyright (c) 2015-2018 Skymind, Inc.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Apache License, Version 2.0 which is available at
 * https://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 ******************************************************************************/

include "array.fbs";
include "utils.fbs";
include "properties.fbs";

namespace nd4j.graph;


// this structure describes single operation within graph
table FlatNode {
    id:int; // unique id for this node
    name:string; // literal id of this node (optional)
    opType:OpType; // type of this op
    opNum:long; // for custom ops that's field for hash, for all other (legacy XYZ ops) that's actually opNum (as defined in legacy_ops.h)
    properties:[FlatProperties]; // optional properties
    input:[int]; // ID's of input nodes for this node !!! only used if inputPaired in unset !!!
    inputPaired:[IntPair]; //list of input variables or nodes, in format of IntPair.first is node Id, IntPair.second is output index of the node
    output:[int]; // ID's of connected nodes for this node

    extraParams:[double]; // extra params for this op (if any)
    extraInteger:[long]; // optional integer extra params
    extraBools:[bool]; // optional  boolean args
    dimensions:[int]; // optional dimension for this operation

    device:int; // default is -1, which means _auto_

    // fields related to Scopes
    scope_id:int; // unique scope id, where this op belongs to
    scope_name:string; // literal scope id, where this op belongs to

    // Additional metadata for helping SameDiff deserialization
    outputNames:[string];       //Name of the SameDiff variable names corresponding to the outputs of this op
    opName:string;              //Used to help resolving the class. In a few cases, multiple classes/opNames are mapped to same hash, and might have different config/properties/differentiability

    // output data types (optional)
    outputTypes:[DataType];
	
	//Scalar value - used for scalar ops. Should be single value only.
	scalar:FlatArray;
}

root_type FlatNode;