}
}
+var _ValidTensorsInfoIds = new Set();
+
+function _CheckIfTensorsInfoNotDisposed(id) {
+ if (false == _ValidTensorsInfoIds.has(id)) {
+ throw new WebAPIException(WebAPIException.ABORT_ERR, 'TensorsInfo is disposed');
+ }
+}
+
var TensorsInfo = function() {
validator_.isConstructorCall(this, TensorsInfo);
id = args.id;
}
+ _ValidTensorsInfoIds.add(id);
+
Object.defineProperties(this, {
count: {
enumerable: true,
];
TensorsInfo.prototype.addTensorInfo = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
var args = validator_.validateArgs(arguments, [
{
name: 'name',
];
TensorsInfo.prototype.clone = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
var callArgs = {
tensorsInfoId: this._id
};
};
TensorsInfo.prototype.equals = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
var args = validator_.validateArgs(arguments, [
{
name: 'other',
};
TensorsInfo.prototype.getDimensions = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
var args = validator_.validateArgs(arguments, [
{
name: 'index',
];
TensorsInfo.prototype.setDimensions = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
var args = validator_.validateArgs(arguments, [
{
name: 'index',
};
TensorsInfo.prototype.getTensorName = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
var args = validator_.validateArgs(arguments, [
{
name: 'index',
};
TensorsInfo.prototype.setTensorName = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
var args = validator_.validateArgs(arguments, [
{
name: 'index',
};
TensorsInfo.prototype.getTensorType = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
var args = validator_.validateArgs(arguments, [
{
name: 'index',
];
TensorsInfo.prototype.setTensorType = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
var args = validator_.validateArgs(arguments, [
{
name: 'index',
};
TensorsInfo.prototype.getTensorSize = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
throw new WebAPIException(WebAPIException.ABORT_ERR, 'Not implemented');
};
TensorsInfo.prototype.getTensorsData = function() {
+ _CheckIfTensorsInfoNotDisposed(this._id);
throw new WebAPIException(WebAPIException.ABORT_ERR, 'Not implemented');
};
TensorsInfo.prototype.dispose = function() {
- throw new WebAPIException(WebAPIException.ABORT_ERR, 'Not implemented');
+ if (false == _ValidTensorsInfoIds.has(this._id)) {
+ return;
+ }
+ var callArgs = {
+ tensorsInfoId: this._id
+ };
+
+ var result = native_.callSync('MLTensorsInfoDispose', callArgs);
+
+ if (native_.isFailure(result)) {
+ return;
+ }
+ _ValidTensorsInfoIds['delete'](this._id);
};
REGISTER_METHOD(MLTensorsInfoSetTensorType);
REGISTER_METHOD(MLTensorsInfoClone);
REGISTER_METHOD(MLTensorsInfoEquals);
+ REGISTER_METHOD(MLTensorsInfoDispose);
// Single API begin
picojson::value val = picojson::value{equals};
ReportSuccess(val, out);
}
+
+void MlInstance::MLTensorsInfoDispose(const picojson::value& args, picojson::object& out) {
+ ScopeLogger("args: %s", args.serialize().c_str());
+ CHECK_ARGS(args, kTensorsInfoId, double, out);
+ int tensorsInfoId = static_cast<int>(args.get(kTensorsInfoId).get<double>());
+
+ PlatformResult result = GetTensorsInfoManager().DisposeTensorsInfo(tensorsInfoId);
+ if (!result) {
+ LogAndReportError(result, &out);
+ }
+ ReportSuccess(out);
+}
// Common ML API end
// Single API begin
return nullptr;
}
+PlatformResult TensorsInfoManager::DisposeTensorsInfo(int id) {
+ ScopeLogger("id: %d", id);
+
+ TensorsInfo* t = GetTensorsInfo(id);
+
+ return DisposeTensorsInfo(t);
+}
+
+PlatformResult TensorsInfoManager::DisposeTensorsInfo(ml_tensors_info_h handle) {
+ ScopeLogger();
+
+ TensorsInfo* t = GetTensorsInfo(handle);
+
+ return DisposeTensorsInfo(t);
+}
+
+PlatformResult TensorsInfoManager::DisposeTensorsInfo(TensorsInfo* t) {
+ ScopeLogger();
+
+ if (nullptr == t) {
+ LoggerE("Could not find tensor");
+ return PlatformResult(ErrorCode::ABORT_ERR);
+ }
+
+ map_by_handle_.erase(t->Handle());
+ map_by_id_.erase(t->Id());
+
+ return PlatformResult(ErrorCode::NO_ERROR);
+}
+
} // ml
} // extension